Example #1
0
int Test_Resource(SaHpiSessionIdT session,
		  SaHpiRptEntryT report, callback2_t func)
{
	SaErrorT status;
	int retval = SAF_TEST_UNKNOWN;
	SaHpiSessionIdT bad_ID;
	SaHpiHsStateT State;

	if (report.ResourceCapabilities & SAHPI_CAPABILITY_MANAGED_HOTSWAP) {
		//
		// rule out the 1::4000000000 chance that this is a valid id
		//
		bad_ID = BAD_SESSION_ID;
		if (session == bad_ID)
			bad_ID++;
		//
		//  Call saHpiHotSwapStateGet passing in a bad SessionId.
		//
		status = saHpiHotSwapStateGet(bad_ID,
					      report.ResourceId, &State);
		if (status != SA_ERR_HPI_INVALID_SESSION) {
			e_print(saHpiHotSwapStateGet,
				SA_ERR_HPI_INVALID_SESSION, status);
			retval = SAF_TEST_FAIL;
		} else
			retval = SAF_TEST_PASS;
	} else			//Resource does not support hot swap
		retval = SAF_TEST_NOTSUPPORT;
	return (retval);
}
Example #2
0
int process_resource(SaHpiSessionIdT session_id, SaHpiRptEntryT rpt_entry,
		     callback2_t func)
{
	SaHpiResourceIdT resource_id;
	SaHpiHsStateT state;
	SaErrorT val;
	int ret = SAF_TEST_UNKNOWN;

	if (rpt_entry.ResourceCapabilities & SAHPI_CAPABILITY_MANAGED_HOTSWAP) {

		resource_id = rpt_entry.ResourceId;

		val = saHpiHotSwapStateGet(session_id, resource_id, &state);
		if (val != SA_OK) {
			e_print(saHpiHotSwapStateGet, SA_OK, val);
			ret = SAF_TEST_FAIL;
		}

		if (ret == SAF_TEST_UNKNOWN) {
			if (state == SAHPI_HS_STATE_NOT_PRESENT) {
				e_print(saHpiHotSwapStateGet,
					state != SAHPI_HS_STATE_NOT_PRESENT,
					val);
				ret = SAF_TEST_FAIL;
			} else
				ret = SAF_TEST_PASS;
		}
	} else {
		// If not a HotSwap Resource
		ret = SAF_TEST_NOTSUPPORT;
	}
	return ret;
}
Example #3
0
int main(int argc, char **argv)
{
	SaHpiSessionIdT sid = 0;
        SaHpiHsStateT state;
	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 hs drive */
        SaHpiResourceIdT resid = get_resid(sid, SAHPI_ENT_DISK_DRIVE_BAY);
        if (resid == 0) {
		dbg("Couldn't find the resource id of the hs drive");
                return -1;
	}

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

	return 0;
}
Example #4
0
int Test_Resource(SaHpiSessionIdT session,
		  SaHpiRptEntryT report, callback2_t func)
{
	SaErrorT status;
	int retval = SAF_TEST_UNKNOWN;
	SaHpiHsStateT State;
	SaHpiBoolT Restore = SAHPI_FALSE;

	if ((report.ResourceCapabilities &
	     SAHPI_CAPABILITY_MANAGED_HOTSWAP) &&
	    (report.ResourceCapabilities & SAHPI_CAPABILITY_FRU)) {
		status =
		    saHpiHotSwapStateGet(session, report.ResourceId, &State);
		if (status != SA_OK) {
			e_print(saHpiHotSwapStateGet, SA_OK, status);
			retval = SAF_TEST_UNRESOLVED;
		}
		if (retval == SAF_TEST_UNKNOWN) {
			switch (State) {
			case SAHPI_HS_STATE_ACTIVE:
				TestCase(session, report.ResourceId, &retval,
					 &Restore);
				break;
			case SAHPI_HS_STATE_EXTRACTION_PENDING:
				Activate(session, report.ResourceId, &retval,
					 &Restore);
				TestCase(session, report.ResourceId, &retval,
					 &Restore);
				Extract(session, report.ResourceId, &retval,
					&Restore);
				break;
			case SAHPI_HS_STATE_INSERTION_PENDING:
				Inactivate(session, report.ResourceId, &retval,
					   &Restore);
				TestCase(session, report.ResourceId, &retval,
					 &Restore);
				Insert(session, report.ResourceId, &retval,
				       &Restore);
				break;
			case SAHPI_HS_STATE_INACTIVE:
				TestCase(session, report.ResourceId, &retval,
					 &Restore);
				break;
			default:
				printf
				    ("  Function \"saHpiHotSwapStateGet\" works abnormally!\n");
				printf("  state recieved is not valid!\n");
				retval = SAF_TEST_UNRESOLVED;
			}
		}
	} else {
		// Not a Hot Swap supported Resource
		retval = SAF_TEST_NOTSUPPORT;
	}
	return (retval);
}
Example #5
0
int Test_Resource(SaHpiSessionIdT session,
		  SaHpiRptEntryT report, callback2_t func)
{
	SaErrorT status;
	int retval = SAF_TEST_UNKNOWN;
	SaHpiHsStateT State;

	if (report.ResourceCapabilities & SAHPI_CAPABILITY_MANAGED_HOTSWAP) {
		//
		//  Call saHpiHotSwapStateGet
		//
		status = saHpiHotSwapStateGet(session,
					      report.ResourceId, &State);
		if (status != SA_OK) {
			e_print(saHpiHotSwapStateGet, SA_OK, status);
			retval = SAF_TEST_FAIL;
		}
	} else			//Resource does not support hot swap
		retval = SAF_TEST_NOTSUPPORT;

	if (retval == SAF_TEST_UNKNOWN) {
		// test for Simplified Hotswap model
		if ((State == SAHPI_HS_STATE_INACTIVE) ||
		    (State == SAHPI_HS_STATE_ACTIVE)) {
			retval = SAF_TEST_PASS;
		}
		// test for Full Hotswap model
		if ((report.ResourceCapabilities & SAHPI_CAPABILITY_FRU) &&
		    ((State == SAHPI_HS_STATE_INSERTION_PENDING) ||
		     (State == SAHPI_HS_STATE_EXTRACTION_PENDING))) {
			retval = SAF_TEST_PASS;
		}
		// Should we get this far without passing then 
		// the test failed
		if (retval == SAF_TEST_UNKNOWN) {
			m_print
			    ("\"saHpiHotSwapStateGet\" returns an invalid Hotswap State: %d",
			     State);
			retval = SAF_TEST_FAIL;
		}
	}
	return (retval);
}
Example #6
0
static int sa_hotswap_stat(SaHpiResourceIdT resourceid)
{
	SaErrorT rv;
	SaHpiHsStateT state;

	rv = saHpiHotSwapStateGet(sessionid, resourceid, &state);
	if (rv != SA_OK) { 
		printf("saHpiHotSwapStateGet error %d\n",rv);
		return -1;
	}

	printf("Current hot swap state of resource %d is:", resourceid);
	switch (state) {
	case SAHPI_HS_STATE_INACTIVE:
		printf("  Inactive.\n");
		break;
	case SAHPI_HS_STATE_INSERTION_PENDING:
		printf("  Insertion Pending.\n");
		break;
	case SAHPI_HS_STATE_ACTIVE_HEALTHY:
		printf("  Active and Healthy.\n");
		break;
	case SAHPI_HS_STATE_ACTIVE_UNHEALTHY:
		printf("  Active but Unhealthy.\n");
		break;
	case SAHPI_HS_STATE_EXTRACTION_PENDING:
		printf("  Extraction Pending.\n");
		break;
	case SAHPI_HS_STATE_NOT_PRESENT:
		printf("  Not Present.\n");
		break;
	default:
		printf("  Unknown.\n");
	}

	return SA_OK;
}
Example #7
0
int show_rpt_list(Domain_t *domain, int as, SaHpiResourceIdT rptid,
	int addedfields, hpi_ui_print_cb_t proc)
/*  as : SHOW_ALL_RPT  -  show all rpt entry only
 *	 SHOW_ALL_RDR  -  show all rdr for all rpt
 *	 SHOW_RPT_RDR  -  show all rdr for rptid
 *  addedfields : SHORT_LSRES - traditional resource list
 *		  STATE_LSRES - show resource status
 *		  PATH_LSRES  - show entity path
 *  return: list size
 */
{
	SaHpiRptEntryT		rpt_entry;
	SaHpiEntryIdT		rptentryid, nextrptentryid;
	int			ind = 0, show_path;
	char			buf[SHOW_BUF_SZ];
	SaErrorT		rv;
	SaHpiCapabilitiesT	cap;
	SaHpiHsCapabilitiesT	hscap;
	SaHpiHsStateT		state;
	rpt_outbuf_t		*rpt_out = NULL, *tmp;
	int			res_num = 0, n_rpt = 0, max_rpt = 0;

	if (as != SHOW_ALL_RPT) show_path = 0;
	else show_path = addedfields & PATH_LSRES;
	rptentryid = SAHPI_FIRST_ENTRY;
	while (rptentryid != SAHPI_LAST_ENTRY) {
		rv = saHpiRptEntryGet(domain->sessionId, rptentryid, &nextrptentryid,
			&rpt_entry);
		if (rv != SA_OK) break;
		if ((as == SHOW_RPT_RDR) && (rpt_entry.ResourceId != rptid)) {
			rptentryid = nextrptentryid;
			continue;
		};
		res_num++;
		snprintf(buf, SHOW_BUF_SZ, "(%3.3d):", rpt_entry.ResourceId);
		get_text_buffer_text(NULL, &(rpt_entry.ResourceTag),
			":", buf + strlen(buf));
		strcat(buf, "{");
		cap = rpt_entry.ResourceCapabilities;
		if (cap & SAHPI_CAPABILITY_SENSOR) strcat(buf, "S|");
		if (cap & SAHPI_CAPABILITY_RDR) strcat(buf, "RDR|");
		if (cap & SAHPI_CAPABILITY_EVENT_LOG) strcat(buf, "ELOG|");
		if (cap & SAHPI_CAPABILITY_INVENTORY_DATA) strcat(buf, "INV|");
		if (cap & SAHPI_CAPABILITY_RESET) strcat(buf, "RST|");
		if (cap & SAHPI_CAPABILITY_POWER) strcat(buf, "PWR|");
		if (cap & SAHPI_CAPABILITY_ANNUNCIATOR) strcat(buf, "AN|");
		if (cap & SAHPI_CAPABILITY_FRU) strcat(buf, "FRU|");
		if (cap & SAHPI_CAPABILITY_CONTROL) strcat(buf, "CNT|");
		if (cap & SAHPI_CAPABILITY_WATCHDOG) strcat(buf, "WTD|");
		if (cap & SAHPI_CAPABILITY_MANAGED_HOTSWAP) strcat(buf, "HS|");
		if (cap & SAHPI_CAPABILITY_CONFIGURATION) strcat(buf, "CF |");
		if (cap & SAHPI_CAPABILITY_AGGREGATE_STATUS) strcat(buf, "AG|");
		if (cap & SAHPI_CAPABILITY_EVT_DEASSERTS) strcat(buf, "DS|");
		if (cap & SAHPI_CAPABILITY_RESOURCE) strcat(buf, "RES|");
		ind  = strlen(buf);
		if (buf[ind - 1] == '|')
			buf[ind - 1] = 0;
		strcat(buf, "}");
		if (addedfields & STATE_LSRES) {
			rv = saHpiHotSwapStateGet(domain->sessionId,
				rpt_entry.ResourceId, &state);
			hscap = rpt_entry.HotSwapCapabilities;
			if ((rv == SA_OK) || (hscap != 0)) {
				strcat(buf, "  HS={");
				if (rv == SA_OK)
					strcat(buf, oh_lookup_hsstate(state));
				if (hscap & SAHPI_HS_CAPABILITY_AUTOEXTRACT_READ_ONLY)
					strcat(buf, " RO|");
				if (hscap & SAHPI_HS_CAPABILITY_INDICATOR_SUPPORTED)
					strcat(buf, " IND|");
				ind  = strlen(buf);
				if (buf[ind - 1] == '|')
					buf[ind - 1] = 0;
				strcat(buf, "}");
			}
		};
		if (show_path) {
			if (n_rpt >= max_rpt) {
				max_rpt += 10;
				tmp = (rpt_outbuf_t *)malloc(sizeof(rpt_outbuf_t) *
						max_rpt);
				memset(tmp, 0, sizeof(rpt_outbuf_t) * max_rpt);
				if (n_rpt > 0) {
					memcpy(tmp, rpt_out,
						sizeof(rpt_outbuf_t) * n_rpt);
					free(rpt_out);
				};
				rpt_out = tmp;
			};
			tmp = rpt_out + n_rpt;
			tmp->len_buf = strlen(buf);
			if (tmp->len_buf > 0) {
				strcpy(tmp->outbuf, buf);
				tmp->path = rpt_entry.ResourceEntity;
				n_rpt++;
			}
		} else {
			strcat(buf, "\n");
			if (proc(buf) != HPI_UI_OK) return(res_num);
			if (as == SHOW_ALL_RDR)
				show_rdr_list(domain, rpt_entry.ResourceId,
					SAHPI_NO_RECORD, proc);
		};
		rptentryid = nextrptentryid;
	};
	if (show_path) {
		print_rpt_paths(rpt_out, n_rpt, proc);
		free(rpt_out);
	};
	return(res_num);
}
Example #8
0
static int
saHpiHotSwapTable_modify_context (SaHpiRptEntryT * rpt_entry,
				  oid * rpt_oid, size_t rpt_oid_len,
				  saHpiHotSwapTable_context * ctx)
{
  unsigned int update_entry = MIB_FALSE;
  long hash = 0;
  int rc;
  SaHpiSessionIdT session_id;
  SaHpiHsIndicatorStateT indication_state;
  SaHpiHsPowerStateT power_state;
  SaHpiResetActionT reset_action;
  SaHpiHsStateT state;
  // These are 64-bite
  SaHpiTimeoutT insert_t;
  SaHpiTimeoutT extract_t;

  if (rpt_entry)
    {
      hash = calculate_hash_value (rpt_entry, sizeof (SaHpiRptEntryT)
				   - sizeof (SaHpiTextBufferT));
    }
  if (ctx)
    {
      if (ctx->hash != 0)
	{
	  DEBUGMSGTL ((AGENT, "Updating HotSwap entry [%d, %d]\n",
		       ctx->domain_id, ctx->resource_id));
	  update_entry = MIB_TRUE;

	}

      if (hash == 0)
	hash = 1;
      ctx->hash = hash;

      if (rpt_entry)
	{
	  ctx->resource_id = rpt_entry->ResourceId;
	  ctx->domain_id = rpt_entry->DomainId;
	  ctx->saHpiHotSwapEventSeverity = rpt_entry->ResourceSeverity + 1;
	}
      // 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;
	}

      // Indicator
      DEBUGMSGTL ((AGENT, "Calling saHpiHotSwapIndicatorStateGet with %d\n",
		   ctx->resource_id));

      rc = saHpiHotSwapIndicatorStateGet (session_id,
					  ctx->resource_id,
					  &indication_state);
      if (rc != SA_OK)
	{
	  DEBUGMSGTL ((AGENT,
		       "Call to saHpiHotSwapIndicatorStateGet failed with rc: %s\n",
		       get_error_string (rc)));
	}
      else
	ctx->saHpiHotSwapIndicator = indication_state + 1;


      // PowerState
      DEBUGMSGTL ((AGENT, "Calling saHpiResourcePowerStateGet with %d\n",
		   ctx->resource_id));

      rc = saHpiResourcePowerStateGet (session_id,
				       ctx->resource_id, &power_state);

      if (rc != SA_OK)
	{
	  DEBUGMSGTL ((AGENT,
		       "Call to saHpiResourcePowerStateGet failed with %s\n",
		       get_error_string (rc)));
	}
      else
	ctx->saHpiHotSwapPowerState = power_state + 1;

      // ResetState
      DEBUGMSGTL ((AGENT, "Calling saHpiResourceResetStateGet with %d\n",
		   ctx->resource_id));

      rc = saHpiResourceResetStateGet (session_id,
				       ctx->resource_id, &reset_action);

      if (rc != SA_OK)
	{
	  DEBUGMSGTL ((AGENT,
		       "Call to saHpiResourceResetStateGet failed with %s\n",
		       get_error_string (rc)));
	}
      else
	ctx->saHpiHotSwapResetState = reset_action + 1;


      // State
      DEBUGMSGTL ((AGENT, "Calling saHpiHotSwapStateGet with %d\n",
		   ctx->resource_id));

      rc = saHpiHotSwapStateGet (session_id, ctx->resource_id, &state);

      if (rc != SA_OK)
	{
	  DEBUGMSGTL ((AGENT, "Call to saHpiHotSwapStateGet failed with %s\n",
		       get_error_string (rc)));
	}
      else
	{
	  ctx->saHpiHotSwapState = state + 1;
	  // We don't know the previous state?
	  ctx->saHpiHotSwapPreviousState = 0;
	}


      // InsertTimeout
      DEBUGMSGTL ((AGENT, "Calling saHpiAutoInsertTimeoutGet \n"));

      rc = saHpiAutoInsertTimeoutGet (session_id, &insert_t);

      if (rc != SA_OK)
	{
	  DEBUGMSGTL ((AGENT,
		       "Call to saHpiAutoInsertTimeoutGet failed with %s\n",
		       get_error_string (rc)));
	}
      else
	// IBM-KR: TODO, saHpiTimeT is 64bit, long is 32bit-
	// Should we make it 64-bit? Endian
	ctx->saHpiHotSwapInsertTimeout = insert_t;

      // Extract timeout
      DEBUGMSGTL ((AGENT, "Calling saHpiAutoExtractTimeoutGet with %d\n",
		   ctx->resource_id));

      rc = saHpiAutoExtractTimeoutGet (session_id,
				       ctx->resource_id, &extract_t);

      if (rc != SA_OK)
	{
	  DEBUGMSGTL ((AGENT,
		       "Call to saHpiAutoExtractTimeoutGet failed with %s\n",
		       get_error_string (rc)));
	}
      else
	{
	  // IBM-KR: TODO, saHpiTimeT is 64bit, long is 32bit-
	  // Should we make it 64-bit? Endian
	  //       
	  ctx->saHpiHotSwapExtractTimeout = extract_t;
	}
      ctx->saHpiHotSwapActionRequest = 0;

      // Copy the RPT OID.
      if (rpt_oid) {
      ctx->saHpiHotSwapRTP_len = rpt_oid_len * sizeof (oid);
      memcpy (ctx->saHpiHotSwapRTP, rpt_oid, ctx->saHpiHotSwapRTP_len);
      }
      if (update_entry == MIB_TRUE)
	return AGENT_ENTRY_EXIST;
      return AGENT_NEW_ENTRY;
    }
  return AGENT_ERR_NULL_DATA;
}
Example #9
0
int main(int argc, char **argv)
{
        int number_resources=0;
        SaErrorT rv;
        SaHpiSessionIdT sessionid;
        SaHpiResourceIdT resourceid;
        SaHpiResourceIdT resourceid_list[RESOURCE_CAP_LENGTH] = {0};
        SaHpiHsStateT hsState;
        SaHpiCapabilitiesT capability = SAHPI_CAPABILITY_MANAGED_HOTSWAP;

        printf("saHpiHotSwapStateGet: Test for hpi hotswap state "
               "get function\n");

        rv = saHpiSessionOpen(SAHPI_UNSPECIFIED_DOMAIN_ID, &sessionid, NULL);
        if (rv != SA_OK) {
                printf("saHpiSessionOpen failed with error: %s\n",
                       oh_lookup_error(rv));
                return rv;
        }

        printf("\nListing the resource with hotswap capability \n");
        rv = discover_resources(sessionid, capability, resourceid_list,
                                &number_resources);
        if (rv != SA_OK) {
                exit(-1);
        }

        printf("\nPlease enter the resource id: ");
        scanf("%d", &resourceid);

        rv = saHpiHotSwapStateGet(sessionid, resourceid, &hsState);
        if (rv != SA_OK) {
                printf("saHpiControlGet failed with error: %s\n",
                       oh_lookup_error(rv));
                printf("Test case - FAIL\n");
        }
        else {
                switch (hsState) {
                        case SAHPI_HS_STATE_INSERTION_PENDING:
                                printf("\n\tHotswap state is "
                                       "INSERTION_PENDING");
                                printf("\nTest case - PASS\n");
                                break;

                        case SAHPI_HS_STATE_ACTIVE:
                                printf("\n\tHotswap state is ACTIVE");
                                printf("\nTest case - PASS\n");
                                break;

                        case SAHPI_HS_STATE_EXTRACTION_PENDING:
                                printf("\n\tHotswap state is "
                                       "EXTRACTION_PENDING");
                                printf("\nTest case - PASS\n");
                                break;

                        case SAHPI_HS_STATE_INACTIVE:
                                printf("\n\tHotswap state is INACTIVE");
                                printf("\nTest case - PASS\n");
                                break;

                        default :
                                printf("\n\tHotswap state is UNKNOWN");
                                printf("\nTest case - FAIL\n");
                }
        }
        rv = saHpiSessionClose(sessionid);
        return 0;
}
Example #10
0
int main(int argc, char **argv)
{
	int                    testfail = 0;
	SaErrorT               err, expected_err;
	SaHpiHsIndicatorStateT hs_ind_state = SAHPI_HS_INDICATOR_OFF;
	SaHpiHsStateT          hs_state = SAHPI_HS_STATE_INACTIVE;
	SaHpiHsActionT         act = 0;
	SaHpiResourceIdT       id = 0;
	SaHpiRptEntryT         rptentry;			
        SaHpiSessionIdT        sessionid;
	SaHpiTimeoutT          timeout = SAHPI_TIMEOUT_IMMEDIATE;

	/*****************************************
	 * Find a resource with hotswap capability
	 *****************************************/
	err = tsetup(&sessionid);
	if (err != SA_OK) {
		printf("Error! Cannot open session\n");
		printf("       File=%s, Line=%d\n", __FILE__, __LINE__);
		return -1;
	}
	err = tfind_resource(&sessionid, SAHPI_CAPABILITY_FRU, SAHPI_FIRST_ENTRY, &rptentry, SAHPI_TRUE);
	if (err != SA_OK) {
		dbg("Cannot find a hotswap resource\n");
		dbg("       File=%s, Line=%d\n", __FILE__, __LINE__);
		err = tcleanup(&sessionid);
		return SA_OK;
	}
	
	id = rptentry.ResourceId;

	/****************************** 
	 * Test: Bad parameter checking
	 ******************************/
	expected_err = SA_ERR_HPI_INVALID_PARAMS;

	err = saHpiAutoInsertTimeoutGet(sessionid, NULL);
	checkstatus(err, expected_err, testfail);

	err = saHpiAutoInsertTimeoutSet(sessionid, -5);
	checkstatus(err, expected_err, testfail);

	err = saHpiAutoExtractTimeoutGet(sessionid, id, NULL);
	checkstatus(err, expected_err, testfail);

	err = saHpiAutoExtractTimeoutSet(sessionid, id, -5);
	checkstatus(err, expected_err, testfail);

	err = saHpiHotSwapStateGet(sessionid, id, NULL);
	checkstatus(err, expected_err, testfail);

	err = saHpiHotSwapActionRequest(sessionid, id, -1);
	checkstatus(err, expected_err, testfail);

	err = saHpiHotSwapIndicatorStateGet(sessionid, id, NULL);
	checkstatus(err, expected_err, testfail);

	err = saHpiHotSwapIndicatorStateSet(sessionid, id, -1);
	checkstatus(err, expected_err, testfail);

	/******************************* 
	 * Test: Invalid session checking
	 *******************************/
	expected_err = SA_ERR_HPI_INVALID_SESSION;

	err = saHpiHotSwapPolicyCancel(-1, id);
	checkstatus(err, expected_err, testfail);

	err = saHpiResourceActiveSet(-1, id);
	checkstatus(err, expected_err, testfail);

	err = saHpiResourceInactiveSet(-1, id);
	checkstatus(err, expected_err, testfail);

	err = saHpiAutoInsertTimeoutGet(-1, &timeout);
	checkstatus(err, expected_err, testfail);

	err = saHpiAutoInsertTimeoutSet(-1, timeout);
	checkstatus(err, expected_err, testfail);

	err = saHpiAutoExtractTimeoutGet(-1, id, &timeout);
	checkstatus(err, expected_err, testfail);

	err = saHpiAutoExtractTimeoutSet(-1, id, timeout);
	checkstatus(err, expected_err, testfail);

	err = saHpiHotSwapStateGet(-1, id, &hs_state);
	checkstatus(err, expected_err, testfail);

	err = saHpiHotSwapActionRequest(-1, id, act);
	checkstatus(err, expected_err, testfail);

	err = saHpiHotSwapIndicatorStateGet(-1, id, &hs_ind_state);
	checkstatus(err, expected_err, testfail);

	err = saHpiHotSwapIndicatorStateSet(-1, id, hs_ind_state);
	checkstatus(err, expected_err, testfail);

	/**************************** 
	 * Test: Invalid RID checking
	 ****************************/
	expected_err = SA_ERR_HPI_INVALID_RESOURCE;

	err = saHpiHotSwapPolicyCancel(sessionid, -1);
	checkstatus(err, expected_err, testfail);

	err = saHpiResourceActiveSet(sessionid, -1);
	checkstatus(err, expected_err, testfail);

	err = saHpiResourceInactiveSet(sessionid, -1);
	checkstatus(err, expected_err, testfail);

	err = saHpiAutoExtractTimeoutGet(sessionid, -1, &timeout);
	checkstatus(err, expected_err, testfail);

	err = saHpiAutoExtractTimeoutSet(sessionid, -1, timeout);
	checkstatus(err, expected_err, testfail);

	err = saHpiHotSwapStateGet(sessionid, -1, &hs_state);
	checkstatus(err, expected_err, testfail);

	err = saHpiHotSwapActionRequest(sessionid, -1, act);
	checkstatus(err, expected_err, testfail);

	err = saHpiHotSwapIndicatorStateGet(sessionid, -1, &hs_ind_state);
	checkstatus(err, expected_err, testfail);

	err = saHpiHotSwapIndicatorStateSet(sessionid, -1, hs_ind_state);
	checkstatus(err, expected_err, testfail);

	/*************************
	 * Cleanup after all tests
	 *************************/
	err = tcleanup(&sessionid);
	return testfail;
}
Example #11
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;
}
Example #12
0
int main(int argc, char **argv) 
{

	/* ************************
	 * Local variables
	 * ***********************/	 
	int testfail = 0;
	SaErrorT          err;
	SaErrorT expected_err;
	SaHpiRptEntryT rptentry;				
	SaHpiResourceIdT  id = 0;
        SaHpiSessionIdT sessionid;
	SaHpiHsStateT state = 0;
	/* *************************************	 	 
	 * Find a resource with Power capability
	 * ************************************* */
	err = tsetup(&sessionid);
	if (err != SA_OK) {
		printf("Error! Can not open session for test environment\n");
		printf("       File=%s, Line=%d\n", __FILE__, __LINE__);
		return -1;
	}

	err = tfind_resource(&sessionid, SAHPI_CAPABILITY_POWER, SAHPI_FIRST_ENTRY, &rptentry, SAHPI_TRUE);
	if (err != SA_OK) {
		printf("Can not find a Power resource for test environment\n");
		printf("       File=%s, Line=%d\n", __FILE__, __LINE__);
		err = tcleanup(&sessionid);
		return SA_OK;
	}
	
	id = rptentry.ResourceId;
	/************************** 
	 * Test: Invalid resource ID
	 **************************/
	struct oh_handler_state l_handle;
	memset(&l_handle, 0, sizeof(struct oh_handler_state));

	expected_err = SA_ERR_HPI_INVALID_RESOURCE;                   
	err = saHpiHotSwapStateGet(sessionid, 5000, &state);
	checkstatus(err, expected_err, testfail);

	/************************** 
	 * Test: Invalid handle 
	 **************************/
	expected_err = SA_ERR_HPI_INVALID_PARAMS;      
	err = snmp_bc_get_hotswap_state(NULL, id, &state);
	checkstatus(err, expected_err, testfail);

	/************************** 
	 * Test:
	 * expected_err = SA_ERR_HPI_INVALID_PARAMS;      
	 **************************/
	err = snmp_bc_get_hotswap_state(&l_handle, id, NULL);
	checkstatus(err, expected_err, testfail);

	/************************** 
	 * Test: Capability checking
	 **************************/
	expected_err = SA_ERR_HPI_CAPABILITY;      
	err = saHpiHotSwapStateGet(sessionid, id, &state);
	checkstatus(err, expected_err, testfail);

	/**************************&*
	 * Cleanup after all tests
	 ***************************/
	err = tcleanup(&sessionid);
	return testfail;

}