Esempio n. 1
0
/*****************************************************************************
Gets called by probe_cpu.  Cycles through the table values until we find
what we are looking for.
*****************************************************************************/
static void search_table(int index, picl_prophdl_t table_hdl) {

  picl_prophdl_t  col_hdl;
  picl_prophdl_t  row_hdl;
  picl_propinfo_t p_info;
  int             val;
  char            string_val[PICL_PROPNAMELEN_MAX];

  for (val = picl_get_next_by_col(table_hdl, &row_hdl); val != PICL_ENDOFLIST;
       val = picl_get_next_by_col(row_hdl, &row_hdl)) {
    if (val == PICL_SUCCESS) {
      for (col_hdl = row_hdl; val != PICL_ENDOFLIST;
           val = picl_get_next_by_row(col_hdl, &col_hdl)) {
        if (val == PICL_SUCCESS) {
          val = picl_get_propinfo(col_hdl, &p_info);
          if (val == PICL_SUCCESS) {
            if (p_info.type == PICL_PTYPE_CHARSTRING) {
              val = picl_get_propval(col_hdl, &string_val, sizeof(string_val));
              if (val == PICL_SUCCESS) {
                assign_string_value(index, string_val);
              }
            }
          }
        }
      }
    }
  }
}
Esempio n. 2
0
/*
 * return the first compatible value
 */
static int
montoya_get_first_compatible_value(picl_nodehdl_t nodeh, char **outbuf)
{
    int		err;
    picl_prophdl_t	proph;
    picl_propinfo_t	pinfo;
    picl_prophdl_t	tblh;
    picl_prophdl_t	rowproph;
    char		*pval;

    err = picl_get_propinfo_by_name(nodeh, OBP_PROP_COMPATIBLE,
                                    &pinfo, &proph);
    if (err != PICL_SUCCESS)
        return (err);

    if (pinfo.type == PICL_PTYPE_CHARSTRING) {
        pval = malloc(pinfo.size);
        if (pval == NULL)
            return (PICL_FAILURE);
        err = picl_get_propval(proph, pval, pinfo.size);
        if (err != PICL_SUCCESS) {
            free(pval);
            return (err);
        }
        *outbuf = pval;
        return (PICL_SUCCESS);
    }

    if (pinfo.type != PICL_PTYPE_TABLE)
        return (PICL_FAILURE);

    /* get first string from table */
    err = picl_get_propval(proph, &tblh, pinfo.size);
    if (err != PICL_SUCCESS)
        return (err);

    err = picl_get_next_by_row(tblh, &rowproph);
    if (err != PICL_SUCCESS)
        return (err);

    err = picl_get_propinfo(rowproph, &pinfo);
    if (err != PICL_SUCCESS)
        return (err);

    pval = malloc(pinfo.size);
    if (pval == NULL)
        return (PICL_FAILURE);

    err = picl_get_propval(rowproph, pval, pinfo.size);
    if (err != PICL_SUCCESS) {
        free(pval);
        return (err);
    }

    *outbuf = pval;
    return (PICL_SUCCESS);
}
Esempio n. 3
0
int32_t
fill_device_from_id(picl_nodehdl_t device_id, char *assoc_id,
		picl_nodehdl_t *device)
{
	int32_t		err;
	picl_prophdl_t	tbl_hdl;
	picl_prophdl_t	reference_property;

	err = picl_get_propval_by_name(device_id, assoc_id, &tbl_hdl,
		sizeof (picl_prophdl_t));
	if (err != PICL_SUCCESS) {
#ifdef WORKFILE_DEBUG
		if (err != PICL_INVALIDHANDLE) {
			log_printf(dgettext(TEXT_DOMAIN,
			"fill_device_from_id failure in "
			"picl_get_propval_by_name err is %s\n"),
			    picl_strerror(err));
		}
#endif
		return (err);
	}

	err = picl_get_next_by_row(tbl_hdl, &reference_property);
	if (err != PICL_SUCCESS) {
#ifdef WORKFILE_DEBUG
		log_printf(dgettext(TEXT_DOMAIN,
		    "fill_device_from_id failure in picl_get_next_by_row"
		    " err is %s\n"), picl_strerror(err));
#endif
		return (err);
	}

	/* get node associated with reference property */
	err = picl_get_propval(reference_property, &(*device),
		sizeof (picl_nodehdl_t));

#ifdef WORKFILE_DEBUG
	if (err != 0) {
		log_printf(dgettext(TEXT_DOMAIN,
		"fill_device_from_id failure in picl_get_propval"
		" err is %s\n"), picl_strerror(err));
	}
#endif

	return (err);
}
Esempio n. 4
0
int32_t
fill_device_array_from_id(picl_nodehdl_t device_id, char *assoc_id,
	int32_t *number_of_devices, picl_nodehdl_t *device_array[])
{
	int32_t		err;
	int		i;
	picl_prophdl_t	tbl_hdl;
	picl_prophdl_t	entry;
	int		devs = 0;

	err = picl_get_propval_by_name(device_id, assoc_id, &tbl_hdl,
		sizeof (picl_prophdl_t));
	if ((err != PICL_SUCCESS) && (err != PICL_INVALIDHANDLE)) {
#ifdef WORKFILE_DEBUG
	    log_printf(dgettext(TEXT_DOMAIN,
	    "fill_device_array_from_id failure in "
	    "picl_get_propval_by_name err is %s\n"), picl_strerror(err));
#endif
	    return (err);
	}

	entry = tbl_hdl;
	while (picl_get_next_by_row(entry, &entry) == 0)
		++devs;

	*device_array = calloc((devs), sizeof (picl_nodehdl_t));
	if (*device_array == NULL) {

#ifdef WORFILE_DEBUG
		log_printf(dgettext(TEXT_DOMAIN,
		"fill_device_array_from_id failure getting memory"
		" for array\n"));
#endif
		return (PICL_FAILURE);
	}

	entry = tbl_hdl;
	for (i = 0; i < devs; i++) {
		err = picl_get_next_by_row(entry, &entry);
		if (err != 0) {
#ifdef WORKFILE_DEBUG
			log_printf(dgettext(TEXT_DOMAIN,
			"fill_device_array_from_id failure in "
			"picl_get_next_by_row err is %s\n"),
			    picl_strerror(err));
#endif
			return (err);
		}

		/* get node associated with reference property */
		err = picl_get_propval(entry, &((*device_array)[i]),
			sizeof (picl_nodehdl_t));
		if (err != 0) {
#ifdef WORKFILE_DEBUG
			log_printf(dgettext(TEXT_DOMAIN,
			"fill_device_array_from_id failure in "
			"picl_get_propval err is %s\n"), picl_strerror(err));
#endif

			return (err);
		}
	}
	*number_of_devices = devs;
	return (err);
}