Beispiel #1
0
static void
piclsbl_init(void)
{
	char	platbuf[SYS_NMLN];

	/* check for Erie platform name */
	if ((sysinfo(SI_PLATFORM, platbuf, SYS_NMLN) != -1) &&
	    ((strcmp(platbuf, ERIE_PLATFORM) == 0) ||
	    (strcmp(platbuf, ERIE_PLATFORM2) == 0)))
		return;

	/* retrieve the root node for lookups in the event handler */
	if ((ptree_get_root(&root_node)) != NULL)
		return;

	/* load libpcp */
	if (load_pcp_libs()) {
		syslog(LOG_ERR, "piclsbl: failed to load libpcp");
		syslog(LOG_ERR, "piclsbl: aborting");
		return;
	}

	/*
	 * register piclsbl_handler for both "sysevent-device-added" and
	 * and for "sysevent-device-removed" PICL events
	 */
	(void) ptree_register_handler(PICLEVENT_SYSEVENT_DEVICE_ADDED,
	    piclsbl_handler, NULL);
	(void) ptree_register_handler(PICLEVENT_SYSEVENT_DEVICE_REMOVED,
	    piclsbl_handler, NULL);
}
Beispiel #2
0
void
env_picl_setup(void)
{
	int		err;
	sensor_node_t	*snodep;
	fan_node_t	*fnodep;
	picl_nodehdl_t	plath;
	char		fullfilename[PATH_MAX];
	picl_nodehdl_t	rooth;

	/*
	 * Initialize sensorp and other fields in the sensor_nodes[] array
	 */
	for (snodep = sensor_nodes; snodep->sensor_name != NULL; snodep++) {
		snodep->sensorp = sensor_lookup(snodep->sensor_name);
		snodep->nodeh = NULL;
		snodep->proph = NULL;
		snodep->sdev_proph = NULL;
	}

	/*
	 * Initialize fanp and other fields in the fan_nodes[] array
	 */
	for (fnodep = fan_nodes; fnodep->fan_name != NULL; fnodep++) {
		fnodep->fanp = fan_lookup(fnodep->fan_name);
		fnodep->nodeh = NULL;
		fnodep->proph = NULL;
	}

	/*
	 * Get platform handle and populate PICL tree with environmental
	 * nodes and properties
	 */
	err = ptree_get_node_by_path("/platform", &plath);

	if (err == PICL_SUCCESS) {
		err = add_sensor_nodes_and_props(plath);
		if (err == PICL_SUCCESS)
			err = add_fan_nodes_and_props(plath);
	}

	if (err != PICL_SUCCESS) {
		envd_log(LOG_CRIT, ENVD_PICL_SETUP_FAILED);
		return;
	}

	/*
	 * Parse the envmodel.conf file and populate the PICL tree
	 */
	if (get_envmodel_conf_file(fullfilename) < 0)
		envd_log(LOG_CRIT, ENVD_PICL_SETUP_FAILED);
	if (ptree_get_root(&rooth) != PICL_SUCCESS)
		envd_log(LOG_CRIT, ENVD_PICL_SETUP_FAILED);
	err = picld_pluginutil_parse_config_file(rooth, fullfilename);

	if (err != PICL_SUCCESS)
		envd_log(LOG_CRIT, ENVD_PICL_SETUP_FAILED);
}
Beispiel #3
0
/*
 * This function returns the handle of the root node of the PICL tree
 */
static void
picld_getroot(picl_service_t *in)
{
	picl_retroot_t	ret;
	int		err;

	ret.cnum = PICL_CNUM_GETROOT;
	err = ptree_get_root(&ret.rnode);
	if (err != PICL_SUCCESS)
		picld_return_error(in->in.cnum, err);
	cvt_ptree2picl(&ret.rnode);
	(void) rw_unlock(&init_lk);
	(void) door_return((char *)&ret, sizeof (picl_retroot_t), NULL, 0);
}
Beispiel #4
0
void
mdescplugin_init(void)
{
	int		status;

	status = ptree_get_root(&root_node);
	if (status != PICL_SUCCESS) {
		return;
	}

	mdp = mdesc_devinit();
	if (mdp == NULL)
		return;

	/*
	 * update the cpu configuration in case the snapshot cache used by the
	 * devtree plugin is out of date.
	 */
	(void) update_devices(OBP_CPU, DEV_ADD);
	(void) update_devices(OBP_CPU, DEV_REMOVE);

	rootnode = md_root_node(mdp);

	/*
	 * This is the start of the CPU property augmentation code.
	 * add_cpu_prop and the rest of the CPU code lives in cpu_prop_update.c
	 */
	status = ptree_walk_tree_by_class(root_node, "cpu", NULL, add_cpu_prop);
	if (status != PICL_SUCCESS) {
		return;
	}

	signal_devtree();

	(void) disk_discovery();

	/*
	 * register dsc_handler for both "sysevent-device-added" and
	 * and for "sysevent-device-removed" PICL events
	 */
	(void) ptree_register_handler(PICLEVENT_SYSEVENT_DEVICE_ADDED,
	    dsc_handler, NULL);
	(void) ptree_register_handler(PICLEVENT_SYSEVENT_DEVICE_REMOVED,
	    dsc_handler, NULL);
	(void) ptree_register_handler(PICLEVENT_DR_AP_STATE_CHANGE,
	    dr_handler, NULL);

	mdesc_devfini(mdp);
}
Beispiel #5
0
static void
piclsbl_init(void)
{
	/* retrieve the root node for lookups in the event handler */
	if ((ptree_get_root(&root_node)) != NULL)
		return;

	/* load libpcp */
	if (load_pcp_libs()) {
		syslog(LOG_ERR, "piclsbl: failed to load libpcp");
		syslog(LOG_ERR, "piclsbl: aborting");
		return;
	}

	/*
	 * register piclsbl_handler for both "sysevent-device-added" and
	 * and for "sysevent-device-removed" PICL events
	 */
	(void) ptree_register_handler(PICLEVENT_SYSEVENT_DEVICE_ADDED,
	    piclsbl_handler, NULL);
	(void) ptree_register_handler(PICLEVENT_SYSEVENT_DEVICE_REMOVED,
	    piclsbl_handler, NULL);
}
Beispiel #6
0
/* Creates and adds all of the frutree nodes */
static int
add_all_nodes()
{
	picl_nodehdl_t	rooth;
	picl_nodehdl_t	chassish;
	int		err;

	/* Get the root node of the PICL tree */
	err = ptree_get_root(&rooth);
	if (err != PICL_SUCCESS) {
		return (err);
	}

	/* Create and add the root node of the FRU subtree */
	err = ptree_create_and_add_node(rooth, "frutree", "picl", &frutreeh);
	if (err != PICL_SUCCESS) {
		syslog(LOG_ERR, CREATE_FRUTREE_FAIL);
		return (err);
	}

	/* Create and add the chassis node */
	err = ptree_create_and_add_node(frutreeh, "chassis", "fru", &chassish);
	if (err != PICL_SUCCESS) {
		syslog(LOG_ERR, CREATE_CHASSIS_FAIL);
		return (err);
	}

	/* Add ViewPoints prop to chassis node */
	err = add_viewpoints_prop(chassish, CHASSIS_VIEWPOINTS);
	if (err != PICL_SUCCESS)
		return (err);

	/* Initialize the FRU nodes for the IO board */
	err = do_ioboard_init(chassish);
	if (err != PICL_SUCCESS) {
		syslog(LOG_ERR, IOBRD_INIT_FAIL);
		return (err);
	}

	/* Initialize the FRU node for the RSC card */
	err = do_rscboard_init(chassish);
	if (err != PICL_SUCCESS) {
		syslog(LOG_ERR, RSCBRD_INIT_FAIL);
		return (err);
	}

	/* Initialize the FRU nodes for the FCAL backplanes and GBIC board */
	err = do_fcal_init(chassish);
	if (err != PICL_SUCCESS) {
		syslog(LOG_ERR, FCAL_INIT_FAIL);
		return (err);
	}

	/* Initialize the FRU nodes for the PDB and the power supplies */
	err = do_power_supplies_init(chassish);
	if (err != PICL_SUCCESS) {
		syslog(LOG_ERR, PS_INIT_FAIL);
		return (err);
	}

	/* Initialize the FRU nodes for the CPU Memory modules */
	err = do_motherboard_init(chassish);
	if (err != PICL_SUCCESS) {
		syslog(LOG_ERR, SYSBOARD_INIT_FAIL);
		return (err);
	}

	return (PICL_SUCCESS);
}
Beispiel #7
0
/*
 * this routine does the following:
 * 1. initializes the CPU geo-addr
 * 2. gets the system name
 * 3. create the chassis type property
 * 4. creates the conf_file property
 */
static picl_errno_t
env_set_cpu_info()
{
	int rc = 0;
	sc_reqmsg_t	req_pkt;
	sc_rspmsg_t	rsp_pkt;
	uint8_t		size = 0;
	char 		conf_name[PICL_PROPNAMELEN_MAX];

	/* get the geo_addr */
	/* initialize the request packet */
	(void) smc_init_smc_msg(&req_pkt, SMC_GET_GEOGRAPHICAL_ADDRESS,
		DEFAULT_SEQN, size);

	/* make a call to smc library to send cmd */
	if (smc_send_msg(DEFAULT_FD, &req_pkt, &rsp_pkt,
		POLL_TIMEOUT) != SMC_SUCCESS) {
		return (PICL_FAILURE);
	}
	cpu_geo_addr = rsp_pkt.data[0];

	/* get the system name */
	if (sysinfo(SI_PLATFORM, sys_name, sizeof (sys_name)) == -1) {
		return (PICL_FAILURE);
	}
	(void) strncpy(chassisconf_name, sys_name,
		sizeof (chassisconf_name));

	/* initialize the node handles */
	if ((rc = ptree_get_root(&rooth)) != PICL_SUCCESS) {
		return (rc);
	}

	if ((rc = ptree_get_node_by_path(FRUTREE_PATH, &frutreeh)) !=
		PICL_SUCCESS) {
		return (rc);
	}

	if ((rc = ptree_get_node_by_path(PICL_FRUTREE_CHASSIS,
		&chassis_nodehdl)) != PICL_SUCCESS) {
		return (rc);
	}

	/* create the chassis type property */
	if ((rc = env_create_property(PICL_PTYPE_CHARSTRING,
		PICL_READ, PICL_PROPNAMELEN_MAX, PICL_PROP_CHASSIS_TYPE,
		NULLREAD, NULLWRITE, chassis_nodehdl, (picl_prophdl_t *)NULL,
		chassisconf_name)) != PICL_SUCCESS) {
		return (rc);
	}

	/*
	 * create dummy prop to inform frutree plugin abt conf file
	 * (rtm based or w/o rtm)
	 * frutree plugin removes this prop after reading the value
	 */
	if (is_rtm_present() == B_TRUE) {
		(void) snprintf(conf_name, sizeof (conf_name),
			"%s.RTM.conf", chassisconf_name);
	} else {
		(void) snprintf(conf_name, sizeof (conf_name),
			"%s.conf", chassisconf_name);
	}

	if ((rc = env_create_property(PICL_PTYPE_CHARSTRING,
		PICL_READ, PICL_PROPNAMELEN_MAX, PICL_PROP_CONF_FILE, NULLREAD,
		NULLWRITE, chassis_nodehdl, (picl_prophdl_t *)NULL,
		conf_name)) != PICL_SUCCESS) {
		return (rc);
	}
	return (PICL_SUCCESS);
}