示例#1
0
static int
locator_walker_func(picl_nodehdl_t nodeh, void *arg)
{
	locator_info_t	*locator_info = (locator_info_t *)arg;
	int		err;
	char		is_locator[PICL_PROPNAMELEN_MAX];
	char		name[PICL_PROPNAMELEN_MAX];
	char		locator_on[PICL_PROPNAMELEN_MAX];
	char		locator_off[PICL_PROPNAMELEN_MAX];

	err = picl_get_propval_by_name(nodeh, "IsLocator", is_locator,
		sizeof (is_locator));

	if (err != PICL_SUCCESS)
		return (PICL_WALK_CONTINUE);

	if (strcmp(is_locator, "true") != 0)
		return (PICL_WALK_CONTINUE);

	err = picl_get_propval_by_name(nodeh, "LocatorName", name,
		sizeof (name));

	if (err == PICL_PROPNOTFOUND)
		err = picl_get_propval_by_name(nodeh, PICL_PROP_NAME, name,
			sizeof (name));

	if (err != PICL_SUCCESS)
		return (err);

	if (strcmp(name, locator_info->name) != 0)
		return (PICL_WALK_CONTINUE);

	err = picl_get_propval_by_name(nodeh, "LocatorOn", locator_on,
		sizeof (locator_on));

	if (err == PICL_SUCCESS) {
		locator_info->on = locator_on;
	} else if (err == PICL_PROPNOTFOUND) {
		locator_info->on = "ON";
	} else {
		return (err);
	}

	err = picl_get_propval_by_name(nodeh, "LocatorOff", locator_off,
		sizeof (locator_off));

	if (err == PICL_SUCCESS) {
		locator_info->off = locator_off;
	} else if (err == PICL_PROPNOTFOUND) {
		locator_info->off = "OFF";
	} else {
		return (err);
	}

	locator_info->err = (locator_info->locator_func)(nodeh,
		locator_info);
	locator_info->found = 1;

	return (PICL_WALK_TERMINATE);
}
示例#2
0
static int
get_child(picl_nodehdl_t nodeh, char *cname, picl_nodehdl_t *resulth)
{
    picl_nodehdl_t  childh;
    picl_nodehdl_t  nexth;

    char            pname[PICL_PROPNAMELEN_MAX];
    picl_errno_t    error_code;

    /* look up first child node */
    error_code = picl_get_propval_by_name(nodeh, PICL_PROP_CHILD, &childh,
                                        sizeof (picl_nodehdl_t));
    if (error_code != PICL_SUCCESS) {
            return (error_code);
    }

    /* step through child nodes, get the name first */
    while (error_code == PICL_SUCCESS) {
        error_code = picl_get_propval_by_name(childh, PICL_PROP_NAME,
                                              pname, (PICL_PROPNAMELEN_MAX - 1));
        if (error_code != PICL_SUCCESS) {  /*we found a node with no name.  Impossible.! */
            return (error_code);
        }

        if (strncmp(pname, cname,PICL_PROPNAMELEN_MAX) == 0){
            *resulth = childh;
            return (PICL_SUCCESS);
        }


        /* look for children of children (note, this is recursive) */

        if (get_child(childh,cname,resulth) == PICL_SUCCESS) {
             return (PICL_SUCCESS);
        }

        /* get next child node at this level*/
            
        error_code = picl_get_propval_by_name(childh, PICL_PROP_PEER,
                                        &nexth, sizeof (picl_nodehdl_t));
        if (error_code != PICL_SUCCESS) {/* no more children - buh bye*/
            return (error_code);
        }

        childh = nexth;

    } /* while */
    return (error_code);
} /* get child */
示例#3
0
static int
display_locator_state(picl_nodehdl_t locator_node,
    locator_info_t *locator_info)
{
	char		state[PICL_PROPNAMELEN_MAX];
	char		*display_state;
	int		err;

	err = picl_get_propval_by_name(locator_node, "State",
		state, sizeof (state));
	if (err != PICL_SUCCESS) {
		(void) fprintf(stderr,
			gettext("picl_get_propval_by_name failed: %s\n"),
			picl_strerror(err));
		return (err);
	}

	if (strcmp(state, locator_info->on) == 0)
		display_state = gettext("on");
	else if (strcmp(state, locator_info->off) == 0)
		display_state = gettext("off");
	else
		display_state = state;

	(void) printf(gettext("The '%s' locator is %s.\n"),
		locator_info->name, display_state);
	return (err);
}
示例#4
0
static int
print_keyswitch(picl_nodehdl_t system_node)
{
	int		err;
	picl_nodehdl_t	*keyswitch;
	int32_t		number;
	char		ks_pos[PICL_PROPNAMELEN_MAX];

	err = fill_device_array_from_id(system_node, "PSVC_KEYSWITCH", &number,
	    &keyswitch);
	if (err != PICL_SUCCESS) {
		return (err);
	}
	err = picl_get_propval_by_name(keyswitch[0], "State", ks_pos,
	    PICL_PROPNAMELEN_MAX);
	if (err != PICL_SUCCESS) {
		free(keyswitch);
		return (err);
	}

	log_printf(dgettext(TEXT_DOMAIN,
	    "Front Status Panel:\n"
	    "-------------------\n"
	    "Keyswitch position: %s\n\n"), ks_pos);
	free(keyswitch);
	return (err);
}
示例#5
0
/*
 * This function copies the node's class into class string
 *
 */
int
erie_get_class(picl_nodehdl_t nodeh, char piclclass[], int size)
{
	int err;
	err = picl_get_propval_by_name(nodeh, PICL_PROP_CLASSNAME,
	    piclclass, size);
	return (err);
}
示例#6
0
/*
 * This function returns assings the string passed in
 * the value of the picl node's name
 *
 */
int
erie_get_name(picl_nodehdl_t nodeh, char name[], int size)
{
	int  err;
	char *compatible;
	char binding_name[MAXSTRLEN];
	char lname[MAXSTRLEN];

	/* Get this node's name */
	err = picl_get_propval_by_name(nodeh, PICL_PROP_NAME, &lname, size);
	if (err == PICL_PROPNOTFOUND) {
		(void) strcpy(lname, "");
		err = PICL_SUCCESS;
	}

	/*
	 * If binding_name is found,
	 * name will be <nodename>-<binding_name>
	 */
	err = picl_get_propval_by_name(nodeh, PICL_PROP_BINDING_NAME,
	    &binding_name, sizeof (binding_name));
	if (err == PICL_SUCCESS) {
		if (strcmp(lname, binding_name) != 0) {
			(void) strlcat(lname, "-", MAXSTRLEN);
			(void) strlcat(lname, binding_name, MAXSTRLEN);
		}
	/*
	 * if compatible prop is not found, name will be
	 * <nodename>-<compatible>
	 */
	} else if (err == PICL_PROPNOTFOUND) {
		err = erie_get_first_compatible_value(nodeh, &compatible);
		if (err == PICL_SUCCESS) {
			(void) strlcat(lname, "-", MAXSTRLEN);
			(void) strlcat(lname, compatible, MAXSTRLEN);
		}
		err = PICL_SUCCESS;
	} else {
		return (err);
	}

	/* The name was created fine, copy it to name var */
	(void) strcpy(name, lname);
	return (err);
}
示例#7
0
static int
print_FSP_LEDS(picl_nodehdl_t system_node)
{
	int		err;
	int32_t		number;
	picl_nodehdl_t	*fsp_led;
	char		fault_state[PICL_PROPNAMELEN_MAX];
	char		locate_state[PICL_PROPNAMELEN_MAX];

	err = fill_device_array_from_id(system_node, "PSVC_FSP_LED", &number,
	    &fsp_led);
	if (err != PICL_SUCCESS) {
		return (err);
	}

	assert(number == 2);
	err = picl_get_propval_by_name(fsp_led[0], "State", &fault_state,
	    PICL_PROPNAMELEN_MAX);
	if (err != PICL_SUCCESS) {
		free(fsp_led);
		return (err);
	}

	if (strcmp(fault_state, PSVC_LED_ON) == 0)
		exit_code = PD_SYSTEM_FAILURE;

	err = picl_get_propval_by_name(fsp_led[1], "State", &locate_state,
	    PICL_PROPNAMELEN_MAX);
	if (err != PICL_SUCCESS) {
		free(fsp_led);
		return (err);
	}

	log_printf(dgettext(TEXT_DOMAIN,
	    "System LED Status:\n\n"
	    "  LOCATOR   FAULT    POWER\n"
	    "  -------  -------  -------\n"
	    "   [%3s]    [%3s]    [ ON]"),
	    locate_state, fault_state);

	log_printf(dgettext(TEXT_DOMAIN,
	    "\n\n=================================\n\n"));
	free(fsp_led);
	return (err);
}
示例#8
0
/*
 * This function gets the path of a node and
 * the error code from the picl API
 *
 */
int
erie_get_path(picl_nodehdl_t nodeh, char path[], int size)
{
	int  err;

	/* hardware path of this node */
	err = picl_get_propval_by_name(nodeh, PICL_PROP_DEVFS_PATH,
	    path, size);
	return (err);
}
示例#9
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);
}
示例#10
0
/*
 * This function copies the node's model into model string
 *
 */
int
erie_get_model(picl_nodehdl_t nodeh, char model[], int size)
{
	int err;
	char tmp_model[MAXSTRLEN];

	/* Get the model of this node */
	err = picl_get_propval_by_name(nodeh, OBP_PROP_MODEL,
	    &tmp_model, size);
	if (err == PICL_PROPNOTFOUND) {
		(void) strcpy(model, "");
		err = PICL_SUCCESS;
	} else {
		(void) strcpy(model, tmp_model);
	}
	return (err);
}
示例#11
0
文件: vbe.c 项目: belenix/belenixold
static int
walk_callback(picl_nodehdl_t nodeh, void *args)
{
        char vga[10];
        picl_propinfo_t pinfo;
        picl_prophdl_t ph;
        /*int i;*/

        if (picl_get_propval_by_name(nodeh, "driver-name", vga, 10) != 0) {
                return (PICL_WALK_CONTINUE);
        }
         
        if (strcmp(vga, "vgatext") != 0) {
                return (PICL_WALK_CONTINUE);
        }
         
        if (picl_get_propinfo_by_name(nodeh, "display-edif-block",
                                &pinfo, &ph) != 0) {
                return (PICL_WALK_TERMINATE);
        }      
               
        mem = (unsigned char *)malloc(pinfo.size);
	if (mem == NULL) {
		return (PICL_WALK_TERMINATE);
	}

        if (picl_get_propval(ph, mem, pinfo.size)) {
                (void) printf("Unable to get block\n");
                return (PICL_WALK_TERMINATE);
        }      
               
        /*(void) printf("display-edif-block = ");
        for (i = 0; i < pinfo.size; i++)
                (void) printf("%02x.", mem[i]);
        (void) putchar('\n');*/
               
        return (PICL_WALK_TERMINATE);
}       
示例#12
0
static int
print_disk(picl_nodehdl_t system_node)
{
	int		i, err;
	int32_t		number;
	picl_nodehdl_t	*disks;
	char		state[PICL_PROPNAMELEN_MAX];

	err = fill_device_array_from_id(system_node, "PSVC_DISK", &number,
	    &disks);
	if (err != PICL_SUCCESS) {
		return (err);
	}

	log_printf(dgettext(TEXT_DOMAIN,
	    "Disk Status:\n"
	    "------------\n"));
	for (i = 0; i < MAX_DISKS; i++) {
		err = picl_get_propval_by_name(disks[i], "FaultInformation",
		    state, PICL_PROPNAMELEN_MAX);

		switch (err) {
		case PICL_SUCCESS:
			log_printf(dgettext(TEXT_DOMAIN,
			    "DISK %d: [%3s]\n"), i, state);
			break;
		case PICL_INVALIDHANDLE:
			log_printf(dgettext(TEXT_DOMAIN,
			    "DISK %d: [ NOT PRESENT ]\n"), i);
			break;
		default:
			free(disks);
			return (err);
		}
	}
	free(disks);
	return (PICL_SUCCESS);
}
示例#13
0
static int
print_temps(picl_nodehdl_t system_node)
{
	int		i;
	int		err;
	picl_nodehdl_t	*system_ts_nodes;
	int32_t		temp;
	int32_t		number;
	char		label[PICL_PROPNAMELEN_MAX];
	char		state[PICL_PROPNAMELEN_MAX];
	char		*p;

	err = fill_device_array_from_id(system_node, "PSVC_TS", &number,
	    &system_ts_nodes);
	if (err != PICL_SUCCESS) {
		return (err);
	}

	log_printf(dgettext(TEXT_DOMAIN,
	    "System Temperatures (Celsius):\n"
	    "-------------------------------\n"
	    "Device\t\tTemperature\tStatus\n"
	    "---------------------------------------\n"));

	for (i = 0; i < number; i++) {
		err = picl_get_propval_by_name(system_ts_nodes[i],
		    "State", state, sizeof (state));
		if (err != PICL_SUCCESS) {
			if (err == PICL_INVALIDHANDLE) {
				(void) strcpy(state, "n/a");
			} else {
				free(system_ts_nodes);
				return (err);
			}
		}
		err = picl_get_propval_by_name(system_ts_nodes[i],
		    PICL_PROP_NAME, label, PICL_PROPNAMELEN_MAX);
		if (err != PICL_SUCCESS) {
			if (err == PICL_INVALIDHANDLE)
				/* This FRU isn't present. Skip it. */
				continue;
			free(system_ts_nodes);
			return (err);
		}

		/*
		 * The names in the tree are like "CPU0_DIE_TEMPERATURE_SENSOR".
		 * All we want to print is up to the first underscore.
		 */
		p = strchr(label, '_');
		if (p != NULL)
			*p = '\0';

		err = picl_get_propval_by_name(system_ts_nodes[i],
		    "Temperature", &temp, sizeof (temp));
		if (err != PICL_SUCCESS) {
			free(system_ts_nodes);
			return (err);
		}
		log_printf("%s\t\t%3d\t\t%s\n", label, temp, state);
	}

	log_printf(dgettext(TEXT_DOMAIN,
	    "\n=================================\n\n"));

	free(system_ts_nodes);
	return (PICL_SUCCESS);
}
示例#14
0
/* ARGSUSED */
static int
montoya_hw_rev_callback(picl_nodehdl_t pcih, void *args)
{
    int		err = PICL_SUCCESS;
    char		path[MAXSTRLEN] = "";
    char		device_path[MAXSTRLEN];
    char		NAC[MAXSTRLEN];
    char		*compatible;
    int32_t		revision;
    int		device_found;

    device_found = 0;

    err = picl_get_propval_by_name(pcih, PICL_PROP_DEVFS_PATH, path,
                                   sizeof (path));
    if (err != PICL_SUCCESS) {
        return (err);
    }


    if ((strncmp(path, NETWORK_0_PATH, strlen(NETWORK_0_PATH)) == 0) ||
            (strncmp(path, NETWORK_1_PATH, strlen(NETWORK_1_PATH)) == 0)) {
        device_found = 1;
        (void) snprintf(NAC, sizeof (NAC), "%s/%s%d",
                        MOTHERBOARD, OPHIR, 0);
        revision = montoya_get_int_propval(pcih, OBP_PROP_REVISION_ID,
                                           &err);
    }

    if ((strncmp(path, NETWORK_2_PATH, strlen(NETWORK_2_PATH)) == 0) ||
            (strncmp(path, NETWORK_3_PATH, strlen(NETWORK_3_PATH)) == 0)) {
        device_found = 1;
        (void) snprintf(NAC, sizeof (NAC), "%s/%s%d",
                        MOTHERBOARD, OPHIR, 1);
        revision = montoya_get_int_propval(pcih, OBP_PROP_REVISION_ID,
                                           &err);
    }

    if ((strcmp(path, FIRE_PATHB) == 0) ||
            (strcmp(path, FIRE_PATHA) == 0)) {
        device_found = 1;
        (void) snprintf(NAC, sizeof (NAC), "%s/%s", MOTHERBOARD,
                        PCI_BRIDGE);
        revision = montoya_get_int_propval(pcih, OBP_PROP_VERSION_NUM,
                                           &err);
    }

    if (strcmp(path, SWITCH_PATH) == 0) {
        device_found = 1;
        (void) snprintf(NAC, sizeof (NAC), "%s/%s",
                        MOTHERBOARD, SWITCH_A);
        revision = montoya_get_int_propval(pcih,
                                           OBP_PROP_REVISION_ID, &err);
    }

    if (strcmp(path, SATA_DISK_PATH) == 0) {
        device_found = 1;
        (void) snprintf(NAC, sizeof (NAC), "%s/%s", RTM, SATA_HBA);
        revision = montoya_get_int_propval(pcih, OBP_PROP_REVISION_ID,
                                           &err);
    }

    if (strcmp(path, RTM_PCI_PATH) == 0) {
        device_found = 1;
        (void) snprintf(NAC, sizeof (NAC), "%s/%s", RTM, AMC);
        revision = montoya_get_int_propval(pcih, OBP_PROP_REVISION_ID,
                                           &err);
    }

    if (device_found == 1) {
        (void) strcpy(device_path, path);
        err = montoya_get_first_compatible_value(pcih, &compatible);

        /* Print NAC name */
        log_printf("%-20s", NAC);
        /* Print Device Path */
        if (strlen(device_path) > 38)
            log_printf("%38.37s+", device_path);
        else
            log_printf("%39s", device_path);

        /* Print Compatible # */
        if (err == PICL_SUCCESS) {
            log_printf("%31s", compatible);
            free(compatible);
        } else
            log_printf("%31s", " ");

        /* Print Revision */
        log_printf("%6d", revision);
        log_printf("\n");
    }

    return (PICL_WALK_CONTINUE);
}
示例#15
0
/* ARGSUSED */
static int
montoya_pci_callback(picl_nodehdl_t pcih, void *args)
{
    int		err = PICL_SUCCESS;
    picl_nodehdl_t	nodeh;
    char		path[MAXSTRLEN];
    char		parent_path[MAXSTRLEN];
    char		piclclass[PICL_CLASSNAMELEN_MAX];
    char		name[MAXSTRLEN];
    char		model[MAXSTRLEN];
    char		*compatible;
    char		binding_name[MAXSTRLEN];
    struct io_card	pci_card;
    int32_t		instance;

    err = picl_get_propval_by_name(pcih, PICL_PROP_DEVFS_PATH, parent_path,
                                   sizeof (parent_path));
    if (err != PICL_SUCCESS) {
        return (err);
    }

    /* Walk through the children */

    err = picl_get_propval_by_name(pcih, PICL_PROP_CHILD, &nodeh,
                                   sizeof (picl_nodehdl_t));

    while (err == PICL_SUCCESS) {
        err = picl_get_propval_by_name(nodeh, PICL_PROP_CLASSNAME,
                                       piclclass, sizeof (piclclass));
        if (err !=  PICL_SUCCESS)
            return (err);

        if (strcmp(piclclass, PCIEX) == 0) {
            err = picl_get_propval_by_name(nodeh, PICL_PROP_PEER,
                                           &nodeh, sizeof (picl_nodehdl_t));
            continue;
        }

        if (strcmp(piclclass, PICL_CLASS_PCI) == 0) {
            err = picl_get_propval_by_name(nodeh, PICL_PROP_CHILD,
                                           &nodeh, sizeof (picl_nodehdl_t));
            continue;
        }

        err = picl_get_propval_by_name(nodeh, PICL_PROP_DEVFS_PATH,
                                       path, sizeof (path));
        if (err != PICL_SUCCESS) {
            return (err);
        }

        (void) strlcpy(pci_card.notes, path, sizeof (pci_card.notes));

        get_bus_type(parent_path, &pci_card);

        get_slot_number(parent_path, &pci_card);

        err = picl_get_propval_by_name(nodeh, PICL_PROP_NAME, &name,
                                       sizeof (name));
        if (err == PICL_PROPNOTFOUND)
            (void) strcpy(name, "");
        else if (err != PICL_SUCCESS)
            return (err);

        /* Figure NAC name */
        if ((strcmp(name, NETWORK) == 0 ||
                strcmp(name, ETHERNET) == 0) &&
                (strcmp(pci_card.slot_str, MOTHERBOARD) == 0)) {
            instance = montoya_get_network_instance(path);

            (void) snprintf(pci_card.status,
                            sizeof (pci_card.status), "%s/%s%d", MOTHERBOARD,
                            "NET", instance);
        } else {
            if (pci_card.slot != -1) {
                (void) snprintf(pci_card.status,
                                sizeof (pci_card.status), "%s/%s%d",
                                IOBOARD, pci_card.bus_type, pci_card.slot);
            } else {
                (void) snprintf(pci_card.status,
                                sizeof (pci_card.status),
                                "%s/%s", MOTHERBOARD, pci_card.bus_type);
            }
        }

        /*
         * Get the name of this card. If binding_name is found,
         * name will be <nodename>-<binding_name>
         */

        err = picl_get_propval_by_name(nodeh, PICL_PROP_BINDING_NAME,
                                       &binding_name, sizeof (binding_name));
        if (err == PICL_PROPNOTFOUND) {
            /*
             * if compatible prop is found, name will be
             * <nodename>-<compatible>
             */
            err = montoya_get_first_compatible_value(nodeh,
                    &compatible);
            if (err == PICL_SUCCESS) {
                (void) strlcat(name, "-", MAXSTRLEN);
                (void) strlcat(name, compatible, MAXSTRLEN);
                free(compatible);
            } else if (err != PICL_PROPNOTFOUND) {
                return (err);
            }
        } else if (err != PICL_SUCCESS) {
            return (err);
        } else if (strcmp(name, binding_name) != 0) {
            (void) strlcat(name, "-", MAXSTRLEN);
            (void) strlcat(name, binding_name, MAXSTRLEN);
        }

        (void) strlcpy(pci_card.name, name, sizeof (pci_card.name));

        /* Get the model of this card */

        err = picl_get_propval_by_name(nodeh, OBP_PROP_MODEL,
                                       &model, sizeof (model));
        if (err == PICL_PROPNOTFOUND)
            (void) strcpy(model, "");
        else if (err != PICL_SUCCESS)
            return (err);
        (void) strlcpy(pci_card.model, model, sizeof (pci_card.model));

        /* Print NAC name */
        log_printf("%-11s", pci_card.status);
        /* Print IO Type */
        log_printf("%6s", pci_card.bus_type);
        /* Print Slot # */
        log_printf("%5s", pci_card.slot_str);
        /* Print Parent Path */
        log_printf("%46.45s", pci_card.notes);
        /* Printf Card Name */
        if (strlen(pci_card.name) > 24)
            log_printf("%25.24s+", pci_card.name);
        else
            log_printf("%26s", pci_card.name);
        /* Print Card Model */
        if (strlen(pci_card.model) > 10)
            log_printf("%10.9s+", pci_card.model);
        else
            log_printf("%10s", pci_card.model);
        log_printf("\n");

        err = picl_get_propval_by_name(nodeh, PICL_PROP_PEER, &nodeh,
                                       sizeof (picl_nodehdl_t));

    }

    return (PICL_WALK_CONTINUE);
}
示例#16
0
文件: pelton.c 项目: andreiw/polaris
/* ARGSUSED */
int
pelton_hw_rev_callback(picl_nodehdl_t pcih, void *args)
{
	int		err = PICL_SUCCESS;
	char		path[MAXSTRLEN] = "";
	char		device_path[MAXSTRLEN];
	char		NAC[MAXSTRLEN];
	char		*compatible;
	int32_t		revision;
	int		device_found;

	device_found = 0;

	err = picl_get_propval_by_name(pcih, PICL_PROP_DEVFS_PATH, path,
	    sizeof (path));
	if (err != PICL_SUCCESS) {
		return (err);
	}

	if ((strcmp(path, PEL_NETWORK_0_PATH) == 0) ||
	    (strcmp(path, PEL_NETWORK_1_PATH) == 0)) {
		device_found = 1;
		(void) snprintf(NAC, sizeof (NAC), "%s/%s%d", IOBOARD, OPHIR,
		    0);
		revision = pelton_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	}

	if ((strcmp(path, PEL_NETWORK_2_PATH) == 0) ||
	    (strcmp(path, PEL_NETWORK_3_PATH) == 0)) {
		device_found = 1;
		(void) snprintf(NAC, sizeof (NAC), "%s/%s%d", IOBOARD, OPHIR,
		    1);
		revision = pelton_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	}

	if ((strcmp(path, FIRE_PATH0) == 0) ||
	    (strcmp(path, FIRE_PATH1) == 0)) {
		device_found = 1;
		(void) snprintf(NAC, sizeof (NAC), "%s/%s", IOBOARD,
		    "IO-BRIDGE");
		revision = pelton_get_int_propval(pcih, OBP_PROP_VERSION_NUM,
		    &err);
	}

	if ((strcmp(path, PEL_PCIX_SLOT0) == 0) ||
	    (strcmp(path, PEL_PCIX_SLOT1) == 0) ||
	    (strcmp(path, PEL_PCIX_SLOT2) == 0) ||
	    (strcmp(path, PEL_PCIX_SLOT3) == 0)) {
		device_found = 1;
		(void) snprintf(NAC, sizeof (NAC), "%s/%s", IOBOARD,
		    PCI_BRIDGE);
		revision = pelton_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	}

	if (strcmp(path, SWITCH_A_PATH) == 0) {
		device_found = 1;
		(void) snprintf(NAC, sizeof (NAC), "%s/%s", IOBOARD, SWITCH_A);
		revision = pelton_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	}

	if (strcmp(path, SWITCH_B_PATH) == 0) {
		device_found = 1;
		(void) snprintf(NAC, sizeof (NAC), "%s/%s", IOBOARD, SWITCH_B);
		revision = pelton_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	}

	if (strcmp(path, PEL_LSI_PATH) == 0) {
		device_found = 1;
		(void) snprintf(NAC, sizeof (NAC), "%s/%s", IOBOARD,
		    PEL_SAS_HBA);
		revision = pelton_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	}
	if (device_found == 1) {
		(void) strcpy(device_path, path);
		err = pelton_get_first_compatible_value(pcih, &compatible);

		/* Print NAC name */
		log_printf("%-20s", NAC);
		/* Print Device Path */
		if (strlen(device_path) > 38)
			log_printf("%38.37s+", device_path);
		else
			log_printf("%39s", device_path);
		/* Print Compatible # */
		log_printf("%31s", compatible);
		free(compatible);
		/* Print Revision */
		log_printf("%6d", revision);
		log_printf("\n");
	}

	return (PICL_WALK_CONTINUE);
}
示例#17
0
static int
process_sensors(int level, picl_nodehdl_t nodeh)
{
    picl_nodehdl_t  childh;
    picl_nodehdl_t  nexth;

    char            propname[PICL_PROPNAMELEN_MAX];
    char            propclass[PICL_CLASSNAMELEN_MAX];
    picl_errno_t    error_code;

    level++;

    DEBUGMSGTL(("ucd-snmp/lmSensors","in process_sensors() level %d\n",level));

    /* look up first child node */
    error_code = picl_get_propval_by_name(nodeh, PICL_PROP_CHILD, &childh,
                                        sizeof (picl_nodehdl_t));
    if (error_code != PICL_SUCCESS) {
                DEBUGMSGTL(("ucd-snmp/lmSensors",
                           "picl_get_propval_by_name(%s) %d\n",
                           PICL_PROP_CHILD, error_code));
                return (error_code);
    }

    /* step through child nodes, get the name first */
    while (error_code == PICL_SUCCESS) {

        error_code = picl_get_propval_by_name(childh, PICL_PROP_NAME,
                                               propname, (PICL_PROPNAMELEN_MAX - 1));
        if (error_code != PICL_SUCCESS) {  /*we found a node with no name.  Impossible.! */
            DEBUGMSGTL(("ucd-snmp/lmSensors",
                       "picl_get_propval_by_name(%s) = %d\n",
                       PICL_PROP_NAME, error_code));
            return (error_code);
        }

        error_code = picl_get_propval_by_name(childh, PICL_PROP_CLASSNAME,
                                                propclass, sizeof (propclass));
        if (error_code != PICL_SUCCESS) {  /*we found a node with no class.  Impossible.! */
            DEBUGMSGTL(("ucd-snmp/lmSensors",
                       "picl_get_propval_by_name(%s) = %d\n",
                       PICL_PROP_CLASSNAME, error_code));
            return (error_code);
        }

        DEBUGMSGTL(("ucd-snmp/lmSensors","found %s of class %s\n",propname,propclass)); 

        if (strstr(propclass,"fan-tachometer"))
           process_individual_fan(childh,propname);
        else if (strstr(propclass,"fan"))
            process_newtype_fan(childh,propname);
        else if (strstr(propclass,"temperature-sensor"))
            process_temperature_sensor(childh,propname);
        else if (strstr(propclass,"voltage-sensor"))
            process_voltage_sensor(childh,propname);
        else if (strstr(propclass,"digital-sensor"))
            process_digital_sensor(childh,propname);
        else if (strstr(propclass,"switch"))
            process_switch(childh,propname);
        else if (strstr(propclass,"led"))
            process_led(childh,propname);
        else if (strstr(propclass,"i2c"))
            process_i2c(childh,propname);
/*
        else if (strstr(propclass,"gpio"))
            process_gpio(childh,propname); 
*/


        /* look for children of children (note, this is recursive) */
       if (!(strstr(propclass,"picl") && 
             (strstr(propname,"frutree") || strstr(propname,"obp")))) {
           error_code = process_sensors(level,childh);
           DEBUGMSGTL(("ucd-snmp/lmSensors",
                      "process_sensors(%s) returned %d\n",
                       propname, error_code));
        }

         /* get next child node at this level*/
        error_code = picl_get_propval_by_name(childh, PICL_PROP_PEER,
                                   &nexth, sizeof (picl_nodehdl_t));
        if (error_code != PICL_SUCCESS) {/* no more children - buh bye*/
           DEBUGMSGTL(("ucd-snmp/lmSensors","Process sensors is out of children!  Returning...\n"));
           return (error_code);
        }

        childh = nexth;

    } /* while */
    return (error_code);
} /* process sensors */
示例#18
0
/* ARGSUSED */
int
huron_hw_rev_callback(picl_nodehdl_t pcih, void *args)
{
	int		err = PICL_SUCCESS;
	char		path[MAXSTRLEN] = "";
	char		device_path[MAXSTRLEN];
	char		NAC[MAXSTRLEN];
	char		*compatible;
	int32_t		revision;
	int		device_found = 0;

	err = picl_get_propval_by_name(pcih, PICL_PROP_DEVFS_PATH, path,
	    sizeof (path));
	if (err != PICL_SUCCESS) {
		return (err);
	}

	if ((strcmp(path, HURON_NETWORK_0) == 0) ||
	    (strcmp(path, HURON_NETWORK_1) == 0)) {
		device_found = 1;
		(void) snprintf(NAC, sizeof (NAC), "%s/%s%d",
		    MOTHERBOARD, OPHIR, 0);
		revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	}

	if ((strcmp(path, HURON_NETWORK_2) == 0) ||
	    (strcmp(path, HURON_NETWORK_3) == 0)) {
		device_found = 1;
		(void) snprintf(NAC, sizeof (NAC), "%s/%s%d", MOTHERBOARD,
		    OPHIR, 1);
		revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	}

	if (strcmp(path, HURON_SWITCH_A_PATH) == 0) {
		device_found = 1;
		(void) snprintf(NAC, sizeof (NAC), "%s/%s",
		    MOTHERBOARD, HURON_SWITCH_A);
		revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	}

	if (strcmp(path, HURON_SWITCH_B_PATH) == 0) {
		device_found = 1;
		(void) snprintf(NAC, sizeof (NAC), "%s/%s", MOTHERBOARD,
		    HURON_SWITCH_B);
		revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	}

	if (strcmp(path, HURON_SWITCH_C_PATH) == 0) {
		device_found = 1;
		(void) snprintf(NAC, sizeof (NAC), "%s/%s", MOTHERBOARD,
		    HURON_SWITCH_C);
		revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	}

	if (strcmp(path, HURON_LSI_PATH) == 0) {
		device_found = 1;
		(void) snprintf(NAC, sizeof (NAC), "%s/%s", MOTHERBOARD,
		    SAS_SATA_HBA);
		revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	}
	if (device_found == 1) {
		(void) strcpy(device_path, path);
		err = huron_get_first_compatible_value(pcih, &compatible);

		/* Print NAC name */
		log_printf("%-20s", NAC);
		/* Print Device Path */
		if (strlen(device_path) > 45)
			log_printf("%45.44s+", device_path);
		else
			log_printf("%46s", device_path);
		/* Print Compatible # */
		if (err == PICL_SUCCESS) {
			log_printf("%31s", compatible);
			free(compatible);
		} else
			log_printf("%31s", " ");
		/* Print Revision */
		log_printf("%6d", revision);
		log_printf("\n");
	}

	return (PICL_WALK_CONTINUE);
}
示例#19
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);
}
示例#20
0
static int
process_sensors(picl_nodehdl_t nodeh)
{
    picl_nodehdl_t  childh;
    picl_nodehdl_t  nexth;

    char            propname[PICL_PROPNAMELEN_MAX];
    char            propclass[PICL_CLASSNAMELEN_MAX];
    picl_errno_t    error_code;

    /* look up first child node */
    error_code = picl_get_propval_by_name(nodeh, PICL_PROP_CHILD, &childh,
                                        sizeof (picl_nodehdl_t));
    if (error_code != PICL_SUCCESS) {
                return (error_code);
    }

    /* step through child nodes, get the name first */
    while (error_code == PICL_SUCCESS) {
        error_code = picl_get_propval_by_name(childh, PICL_PROP_NAME,
                                               propname, (PICL_PROPNAMELEN_MAX - 1));
        if (error_code != PICL_SUCCESS) {  /*we found a node with no name.  Impossible.! */
            return (error_code);
        }

        if (strcmp(propname,PICL_NODE_PLATFORM)==0){ /*end of the chain*/
                return (255);
        }

        error_code = picl_get_propval_by_name(childh, PICL_PROP_CLASSNAME,
                                                propclass, sizeof (propclass));
        if (error_code != PICL_SUCCESS) {  /*we found a node with no class.  Impossible.! */
            return (error_code);
        }

/*        DEBUGMSGTL(("ucd-snmp/lmSensors","found %s of class %s\n",propname,propclass)); */

        if (strstr(propclass,"fan-tachometer"))
            process_individual_fan(childh,propname);
        if (strstr(propclass,"temperature-sensor"))
            process_temperature_sensor(childh,propname);
        if (strstr(propclass,"digital-sensor"))
            process_digital_sensor(childh,propname);
        if (strstr(propclass,"switch"))
            process_switch(childh,propname);
        if (strstr(propclass,"led"))
            process_led(childh,propname);
        if (strstr(propclass,"i2c"))
            process_i2c(childh,propname);
/*
        if (strstr(propclass,"gpio"))
            process_gpio(childh,propname); 
*/


           /* look for children of children (note, this is recursive) */
 
        if (process_sensors(childh) == PICL_SUCCESS) {
            return (PICL_SUCCESS);
        }

          /* get next child node at this level*/
        error_code = picl_get_propval_by_name(childh, PICL_PROP_PEER,
                                        &nexth, sizeof (picl_nodehdl_t));
        if (error_code != PICL_SUCCESS) {/* no more children - buh bye*/
            return (error_code);
        }

        childh = nexth;

    } /* while */
    return (error_code);
} /* process sensors */
示例#21
0
/* ARGSUSED */
int
erie_hw_rev_callback(picl_nodehdl_t pcih, void *args)
{
	int		err = PICL_SUCCESS;
	char		path[MAXSTRLEN] = "";
	char		nac[MAXSTRLEN];
	char		*compatible;
	int32_t		revision;

	/* Get path of this device */
	err = picl_get_propval_by_name(pcih, PICL_PROP_DEVFS_PATH, path,
	    sizeof (path));
	if (err != PICL_SUCCESS) {
		return (err);
	}
	/*
	 * If it's a network dev, then print network info.
	 * Else if it's not a network dev,  check for FIRE ASIC
	 * Else return PICL_WALK_CONTINUE
	 */
	if ((strcmp(path, ERIE_NETWORK_0) == 0) ||
	    (strcmp(path, ERIE_NETWORK_1) == 0)) {
		(void) snprintf(nac, sizeof (nac), "%s/%s%d", MOTHERBOARD,
		    OPHIR, 0);
		revision = erie_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	} else if ((strcmp(path, ERIE_NETWORK_2) == 0) ||
	    (strcmp(path, ERIE_NETWORK_3) == 0)) {
		(void) snprintf(nac, sizeof (nac), "%s/%s%d", MOTHERBOARD,
		    OPHIR, 1);
		revision = erie_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	} else if ((strcmp(path, ERIE_LSI_PATH) == 0)) {
		(void) snprintf(nac, sizeof (nac), "%s/%s", MOTHERBOARD,
		    SAS_SATA_HBA);
		revision = erie_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	} else if ((strcmp(path, FIRE0) == 0) || (strcmp(path, FIRE1) == 0)) {
		(void) snprintf(nac, sizeof (nac), "%s/%s", MOTHERBOARD,
		    IOBRIDGE);
		revision = erie_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	} else if ((strcmp(path, PCIE_PCIX) == 0) ||
	    (strcmp(path, PCIE_PCIE) == 0)) {
		(void) snprintf(nac, sizeof (nac), "%s/%s", MOTHERBOARD,
		    PCI_BRIDGE);
		revision = erie_get_int_propval(pcih, OBP_PROP_REVISION_ID,
		    &err);
	} else {
		return (PICL_WALK_CONTINUE);
	}

	/* Get first compatible value from picl compatible list */
	err = erie_get_first_compatible_value(pcih, &compatible);
	if (err != PICL_SUCCESS) {
		return (err);
	}

	/* Print nacation */
	log_printf("%-20s", nac);

	/* Print Device Path */
	log_printf("%41s", path);

	/* Print Compatible # */
	log_printf("%31s", compatible);
	free(compatible);

	/* Print Revision */
	log_printf("%6d", revision);
	log_printf("\n");

	return (PICL_WALK_CONTINUE);
}
示例#22
0
static int
print_fans(picl_nodehdl_t system_node)
{
	int		i, err;
	int32_t		number;
	picl_nodehdl_t	*fans;
	picl_nodehdl_t	phdl;
	char		prop[PICL_PROPNAMELEN_MAX];
	char		parent[PICL_PROPNAMELEN_MAX];
	int32_t		rpm;

	err = fill_device_array_from_id(system_node, "PSVC_FAN", &number,
	    &fans);
	if (err != PICL_SUCCESS) {
		return (err);
	}

	log_printf(dgettext(TEXT_DOMAIN,
	    "\n=================================\n\n"
	    "Fan Status:\n"
	    "-----------\n\n"
	    "Fan Tray        Fan              RPM    Status\n"
	    "-----------     ----            -----   ----------\n"));

	for (i = 0; i < MAX_FANS; i++) {
		err = picl_get_propval_by_name(fans[i], PICL_PROP_NAME, prop,
		    PICL_PROPNAMELEN_MAX);
		if (err != PICL_SUCCESS)
			continue;

		err = fill_device_from_id(fans[i], "PSVC_PARENT", &phdl);
		if (err != PICL_SUCCESS)
			continue;
		err = picl_get_propval_by_name(phdl, PICL_PROP_NAME, parent,
		    PICL_PROPNAMELEN_MAX);
		if (err != PICL_SUCCESS)
			continue;

		log_printf(dgettext(TEXT_DOMAIN, "%-16s"), parent);


		log_printf(dgettext(TEXT_DOMAIN, "%-16s"), prop);

		err = picl_get_propval_by_name(fans[i], "Fan-speed",
		    &rpm, sizeof (rpm));
		if (err != PICL_SUCCESS) {
			free(fans);
			return (err);
		}
		log_printf(dgettext(TEXT_DOMAIN, "%5d "), rpm);

		err = picl_get_propval_by_name(fans[i], "FaultInformation",
		    prop, PICL_PROPNAMELEN_MAX);
		if (err != PICL_SUCCESS) {
			free(fans);
			return (err);
		}
		log_printf(dgettext(TEXT_DOMAIN, "  [%s]\n"), prop);
	}
	log_printf(dgettext(TEXT_DOMAIN,
	    "\n=================================\n\n"));
	free(fans);
	return (PICL_SUCCESS);
}
示例#23
0
static int
print_ps(picl_nodehdl_t system_node)
{
	int		i, j, err = 0;
	int32_t		number;
	picl_nodehdl_t	*ps;
	picl_nodehdl_t	*ps_fail_sensor;
	char		name[PICL_PROPNAMELEN_MAX];
	char		fault_state[PICL_PROPNAMELEN_MAX];

	log_printf(dgettext(TEXT_DOMAIN, "\n\n"
	    "Power Supplies:\n"
	    "---------------\n"
	    "\n"
	    "Supply     Status        Fault     Fan Fail   Temp Fail\n"
	    "------    ------------   --------  ---------  ---------\n"));

	err = fill_device_array_from_id(system_node, "PSVC_PS", &number, &ps);
	if (err != PICL_SUCCESS) {
		return (err);
	}

	for (i = 0; i < MAX_PS; i++) {
		err = picl_get_propval_by_name(ps[i], PICL_PROP_NAME, name,
		    PICL_PROPNAMELEN_MAX);
		if (err != PICL_SUCCESS)
			continue;

		log_printf(dgettext(TEXT_DOMAIN, "%6-s"), name);
		err = picl_get_propval_by_name(ps[i], "FaultInformation",
		    fault_state, PICL_PROPNAMELEN_MAX);
		if (err != PICL_SUCCESS) {
			free(ps);
			return (err);
		}
		log_printf(dgettext(TEXT_DOMAIN, "   [%-12s]"), fault_state);
		if (strcmp(fault_state, "NO AC POWER") == 0) {
			log_printf("\n");
			continue;
		}

		err = fill_device_array_from_id(ps[i], "PSVC_DEV_FAULT_SENSOR",
		    &number, &ps_fail_sensor);

		if (err != PICL_SUCCESS) {
			free(ps);
			return (err);
		}
		log_printf("   ");
		for (j = 0; j < MAX_PS_SENSORS; j++) {
			err = picl_get_propval_by_name(ps_fail_sensor[j],
			    "State", fault_state, PICL_PROPNAMELEN_MAX);
			if (err != PICL_SUCCESS) {
				if (err == PICL_FAILURE) {
					break;
				}
				free(ps);
				free(ps_fail_sensor);
				return (err);
			}
			log_printf(dgettext(TEXT_DOMAIN, "%-10s"), fault_state);
		}
		log_printf("\n");
		free(ps_fail_sensor);
	}

	log_printf(dgettext(TEXT_DOMAIN,
	    "\n=================================\n\n"));

	free(ps);
	return (PICL_SUCCESS);
}
示例#24
0
/* ARGSUSED */
int
erie_pci_callback(picl_nodehdl_t pcih, void *args)
{
	int		err = PICL_SUCCESS;
	picl_nodehdl_t	nodeh;
	char		path[MAXSTRLEN];
	char		parent_path[MAXSTRLEN];
	char		piclclass[PICL_CLASSNAMELEN_MAX];
	char		name[MAXSTRLEN];
	char		model[MAXSTRLEN];
	char		nac[MAXSTRLEN];
	char		bus_type[MAXSTRLEN];
	int		slot = NO_SLOT;

	/* Get the parent node's path - used to determine bus type of child */
	err = picl_get_propval_by_name(pcih, PICL_PROP_DEVFS_PATH, parent_path,
	    sizeof (parent_path));
	if (err != PICL_SUCCESS) {
		return (err);
	}

	/* Walk through this node's children */
	err = picl_get_propval_by_name(pcih, PICL_PROP_CHILD, &nodeh,
	    sizeof (picl_nodehdl_t));
	while (err == PICL_SUCCESS) {

		/* Get child's class */
		if ((err = erie_get_class(nodeh, piclclass,
		    sizeof (piclclass))) != PICL_SUCCESS)
			return (err);

		/* If this node is a pci bus or bridge, get node's sibling */
		if ((strcmp(piclclass, "pci") == 0 ||
		    (strcmp(piclclass, "pciex") == 0))) {
			err = picl_get_propval_by_name(nodeh, PICL_PROP_PEER,
			    &nodeh, sizeof (picl_nodehdl_t));
			continue;
		}

		/*
		 * In order to get certain values, it's necessary
		 * to search the picl tree. If there's a problem
		 * with these searches, we'll return the err
		 */
		if ((err = erie_get_path(nodeh, path, sizeof (path)))
		    != PICL_SUCCESS)
			return (err);
		if ((err = erie_get_name(nodeh, name, sizeof (name)))
		    != PICL_SUCCESS)
			return (err);
		if ((err = erie_get_model(nodeh, model, sizeof (model)))
		    != PICL_SUCCESS)
			return (err);
		erie_get_bus_type(parent_path, bus_type);
		slot = erie_get_slot_number(path);
		erie_get_nac(bus_type, path, slot, name, nac, sizeof (nac));


		/* Print out the data */

		/* Print NAC */
		log_printf("%-11s", nac);

		/* Print IO Type */
		log_printf("%-6s", bus_type);

		/* Print Slot # */
		if (slot != NO_SLOT) {
			log_printf("%5d", slot);
			log_printf("%46s", path);
		} else {
			log_printf("%5s", MOTHERBOARD);
			log_printf("%46s", path);
		}

		/* Printf Node Name */
		if (strlen(name) > 25)
			log_printf("%25.24s+", name);
		else
			log_printf("%26s", name);
		/* Print Card Model */
		if (strlen(model) > 10)
			log_printf("%10.9s+", model);
		else
			log_printf("%11s", model);
		log_printf("\n");

		/* Grab the next child under parent node and do it again */
		err = picl_get_propval_by_name(nodeh, PICL_PROP_PEER, &nodeh,
		    sizeof (picl_nodehdl_t));
	}
	return (PICL_WALK_CONTINUE);
}
示例#25
0
/*
 *  Recursively walk through the tree of sensors
 */
static int
process_sensors( int level, picl_nodehdl_t nodeh ) {
    picl_nodehdl_t childh, nexth;
    char           propname[  PICL_PROPNAMELEN_MAX  ];
    char           propclass[ PICL_CLASSNAMELEN_MAX ];
    picl_errno_t   error_code;

    level++;
    DEBUGMSGTL(("sensors:arch:detail", "process_sensors - level %d\n", level));

    /* Look up the first child node at this level */
    error_code = picl_get_propval_by_name( nodeh, PICL_PROP_CHILD,
                                           &childh, sizeof(childh));
    if ( error_code != PICL_SUCCESS ) {
        DEBUGMSGTL(("sensors:arch:detail", "Failed to get first child node (%d)\n",
                                            error_code));
        return( error_code );
    }

    /* Step through the child nodes, retrieving the name and class of each one */
    while ( error_code == PICL_SUCCESS ) {
        error_code = picl_get_propval_by_name( childh, PICL_PROP_NAME,
                                               propname, sizeof(propname)-1);
        if ( error_code != PICL_SUCCESS ) {
            /* The Node With No Name */
            DEBUGMSGTL(("sensors:arch:detail", "get property name failed (%d)\n",
                                                error_code));
            return( error_code );
        }

        error_code = picl_get_propval_by_name( childh, PICL_PROP_CLASSNAME,
                                               propclass, sizeof(propclass)-1);
        if ( error_code != PICL_SUCCESS ) {
            /* The Classless Society */
            DEBUGMSGTL(("sensors:arch:detail", "get property class failed (%d)\n",
                                                error_code));
            return( error_code );
        }

        DEBUGMSGTL(("sensors:arch:detail", "Name: %s, Class %s\n",
                                            propname, propclass ));


        /*
         *  Three classes represent further groups of sensors, etc.
         *  Call 'process_sensors' recursively to handle this next level
         */
        if (( strstr( propclass, "picl"    )) ||
            ( strstr( propclass, "frutree" )) ||
            ( strstr( propclass, "obp"     ))) {
            process_sensors( level, childh );
        }
        /*
         *  Otherwise retrieve the value appropriately based on the
         *     class of the sensor.
         *
         *  We need to specify the name of the PICL property to retrieve
         *     for this class of sensor, and the Net-SNMP sensor type.
         */
        else if ( strstr( propclass, "fan-tachometer" )) {
            process_num_sensor( childh, propname, "AtoDSensorValue",
                                                   NETSNMP_SENSOR_TYPE_RPM );
        } else if ( strstr( propclass, "fan" )) {
            process_num_sensor( childh, propname, "Speed",
                                                   NETSNMP_SENSOR_TYPE_RPM );
        } else if ( strstr( propclass, "temperature-sensor" )) {
            process_num_sensor( childh, propname, "Temperature",
                                                   NETSNMP_SENSOR_TYPE_TEMPERATURE );
        } else if ( strstr( propclass, "voltage-sensor" )) {
            process_num_sensor( childh, propname, "Voltage",
                                          /* ?? */ NETSNMP_SENSOR_TYPE_VOLTAGE_DC );
        } else if ( strstr( propclass, "digital-sensor" )) {
            process_num_sensor( childh, propname, "AtoDSensorValue",
                                          /* ?? */ NETSNMP_SENSOR_TYPE_VOLTAGE_DC );
            /*
             * Enumeration-valued sensors use a fixed PICL property ("State"),
             *   but take a list of the values appropriate for that sensor,
             *   as well as the Net-SNMP sensor type.
             */
        } else if ( strstr( propclass, "switch" )) {
            process_enum_sensor( childh, propname, NETSNMP_SENSOR_TYPE_OTHER,
                                                   switch_settings );
        } else if ( strstr( propclass, "led" )) {
            process_enum_sensor( childh, propname, NETSNMP_SENSOR_TYPE_OTHER,
                                                   led_settings );
        } else if ( strstr( propclass, "i2c" )) {
            process_enum_sensor( childh, propname, NETSNMP_SENSOR_TYPE_BOOLEAN, /* ?? */
                                                   i2c_settings );
        } else {
            /* Skip other classes of sensor */
            DEBUGMSGTL(("sensors:arch:detail", "Skipping class %s\n", propclass ));
        }

        /*
         *  Move on to the next child node at the current level (if any)
         */
        error_code = picl_get_propval_by_name( childh, PICL_PROP_PEER,
                                               &nexth, sizeof(nexth));
        if ( error_code != PICL_SUCCESS ) {
            /* That's All Folks! */
            return (( error_code == PICL_PROPNOTFOUND )
                          ? PICL_SUCCESS : error_code );
        }
        childh = nexth;
    }
    
    return error_code;
}
示例#26
0
int32_t
find_child_device(picl_nodehdl_t parent, char *child_name,
		picl_nodehdl_t *child)
{
	int32_t		err;
	char		name[PICL_PROPNAMELEN_MAX];

	err = picl_get_propval_by_name(parent, PICL_PROP_CHILD, &(*child),
		sizeof (picl_nodehdl_t));
	switch (err) {
	case PICL_SUCCESS:
		break;
	case PICL_PROPNOTFOUND:
		err = PICL_INVALIDHANDLE;
		return (err);
	default:
#ifdef WORKFILE_DEBUG
		log_printf(dgettext(TEXT_DOMAIN,
		    "Failed picl_get_propval_by_name with %s\n"),
		    picl_strerror(err));
#endif
		return (err);
	}

	err = picl_get_propval_by_name(*child, PICL_PROP_NAME, name,
	    PICL_PROPNAMELEN_MAX);

#ifdef WORKFILE_DEBUG
	if (err != PICL_SUCCESS) {
		log_printf(dgettext(TEXT_DOMAIN,
		    "failed the get name for root\n"));
		log_printf(dgettext(TEXT_DOMAIN, "%s\n"), picl_strerror(err));
	}
#endif

	if (strcmp(name, child_name) == 0)
		return (err);

	while (err != PICL_PROPNOTFOUND) {
#ifdef WORKFILE_DEBUG
		log_printf(dgettext(TEXT_DOMAIN, "child name is %s\n"), name);
#endif
		err = picl_get_propval_by_name(*child, PICL_PROP_PEER,
			&(*child), sizeof (picl_nodehdl_t));
		switch (err) {
		case PICL_SUCCESS:
			err = picl_get_propval_by_name(*child, PICL_PROP_NAME,
			    name, PICL_PROPNAMELEN_MAX);
			if (strcmp(name, child_name) == 0)
				return (err);
			break;
		case PICL_PROPNOTFOUND:
			break;
		default:
#ifdef WORKFILE_DEBUG
			log_printf(dgettext(TEXT_DOMAIN,
			    "Failed picl_get_propval_by_name with %s\n"),
			    picl_strerror(err));
#endif
			return (err);
		}
	}
	err = PICL_INVALIDHANDLE;
	return (err);
}