3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * CDDL HEADER START
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * The contents of this file are subject to the terms of the
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Common Development and Distribution License, Version 1.0 only
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * (the "License"). You may not use this file except in compliance
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * with the License.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * See the License for the specific language governing permissions
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * and limitations under the License.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * When distributing Covered Code, include this CDDL HEADER in each
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * If applicable, add the following below this CDDL HEADER, with the
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * fields enclosed by brackets "[]" replaced with your own identifying
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * information: Portions Copyright [yyyy] [name of copyright owner]
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * CDDL HEADER END
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Use is subject to license terms.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs#pragma ident "%Z%%M% %I% %E% SMI"
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * PICL plug-in that creates the FRU Hierarchy for the
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * SUNW,Sun-Fire-480R (Cherrystone) platform
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Plugin registration entry points
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic void picl_frutree_register(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic void picl_frutree_init(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic void picl_frutree_fini(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic void picl_frutree_evhandler(const char *ename, const void *earg,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Log message texts
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs#define CREATE_FRUTREE_FAIL gettext("Failed to create frutree node\n")
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs#define CREATE_CHASSIS_FAIL gettext("Failed to create chassis node\n")
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs#define IOBRD_INIT_FAIL gettext("do_ioboard_init() failed\n")
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs#define RSCBRD_INIT_FAIL gettext("do_rscboard_init() failed\n")
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs#define PS_INIT_FAIL gettext("do_power_supplies_init() failed\n")
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs#define SYSBOARD_INIT_FAIL gettext("do_centerplane_init() failed\n")
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Viewpoints property field used by SunMC
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Ref prop values
1c29f7e382074ff2792b7f30c9be898ead487a30Qiyan Sun - Sun Microsystems - San Diego United States#define SEEPROM_SOURCE "_seeprom_source"
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * List of all the FRU locations in the platform_frupath[] array, and
fd9489cef0e9b7d8a708339e560d453f230af2cfQiyan Sun - Sun Microsystems - San Diego United States * location_label[] array
a512c5d1f2908d965887ad5494954ba2cf904bd2Qiyan Sun - Sun Microsystems - San Diego United States#define CENTERPLANE 5
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Local variables
1c29f7e382074ff2792b7f30c9be898ead487a30Qiyan Sun - Sun Microsystems - San Diego United States "SUNW_Cherrystone_frutree",
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * List of all the FRUs in the /platform tree with SEEPROMs
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,30/fru@0,a2", /* PS 0 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,30/fru@0,a0", /* PS 1 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,30/fru@0,a6", /* RSC */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,30/fru@0,a8", /* Disk Backplane */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,30/fru@0,ae", /* PDB */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@4,a8", /* Centerplane */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@4,aa", /* IO */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@4,a0", /* CPU MOD 0 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@4,a2", /* CPU MOD 1 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@0,a0", /* CPU0 DIMM0 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@0,a2", /* CPU0 DIMM1 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@0,a4", /* CPU0 DIMM2 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@0,a6", /* CPU0 DIMM3 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@0,a8", /* CPU0 DIMM4 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@0,aa", /* CPU0 DIMM5 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@0,ac", /* CPU0 DIMM6 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@0,ae", /* CPU0 DIMM7 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@2,a0", /* CPU2 DIMM0 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@2,a2", /* CPU2 DIMM1 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@2,a4", /* CPU2 DIMM2 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@2,a6", /* CPU2 DIMM3 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@2,a8", /* CPU2 DIMM4 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@2,aa", /* CPU2 DIMM5 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@2,ac", /* CPU2 DIMM6 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@2,ae", /* CPU2 DIMM7 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@1,a0", /* CPU1 DIMM0 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@1,a2", /* CPU1 DIMM1 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@1,a4", /* CPU1 DIMM2 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@1,a6", /* CPU1 DIMM3 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@1,a8", /* CPU1 DIMM4 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@1,aa", /* CPU1 DIMM5 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@1,ac", /* CPU1 DIMM6 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@1,ae", /* CPU1 DIMM7 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@3,a0", /* CPU3 DIMM0 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@3,a2", /* CPU3 DIMM1 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@3,a4", /* CPU3 DIMM2 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@3,a6", /* CPU3 DIMM3 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@3,a8", /* CPU3 DIMM4 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@3,aa", /* CPU3 DIMM5 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@3,ac", /* CPU3 DIMM6 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/platform/pci@9,700000/ebus@1/i2c@1,2e/fru@3,ae", /* CPU3 DIMM7 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * List of Labels for FRU locations (uses the #define's from above)
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * List of all the FRU slots for power supplies (hotpluggable)
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/frutree/chassis/power-dist-board/power-supply-slot?Slot=0",
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs "/frutree/chassis/power-dist-board/power-supply-slot?Slot=1",
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* PICL handle for the root node of the "frutree" */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic int add_ref_prop(picl_nodehdl_t, picl_nodehdl_t, char *);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic int add_all_nodes();
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic int add_hotplug_fru_device(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic int rem_hotplug_fru_device(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic int is_added_device(char *, char *);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic int is_removed_device(char *, char *);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic int add_power_supply(int);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic int remove_power_supply(int);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * This function is executed as part of .init when the plugin is
fe930412c257f961ae67039de3b164b83717976aqs * dlopen()ed
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic void
fe930412c257f961ae67039de3b164b83717976aqs * This function is the init entry point of the plugin.
fe930412c257f961ae67039de3b164b83717976aqs * It initializes the /frutree tree
fe930412c257f961ae67039de3b164b83717976aqsstatic void
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Register the event handler routine */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs (void) ptree_register_handler(PICLEVENT_SYSEVENT_DEVICE_ADDED,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs (void) ptree_register_handler(PICLEVENT_SYSEVENT_DEVICE_REMOVED,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * This function is the fini entry point of the plugin
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic void
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Unregister the event handler routine */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs (void) ptree_unregister_handler(PICLEVENT_SYSEVENT_DEVICE_ADDED,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs (void) ptree_unregister_handler(PICLEVENT_SYSEVENT_DEVICE_REMOVED,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * This function is the event handler of this plug-in.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * It processes the following events:
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * PICLEVENT_SYSEVENT_DEVICE_ADDED
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * PICLEVENT_SYSEVENT_DEVICE_REMOVED
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* ARGSUSED */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic void
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qspicl_frutree_evhandler(const char *ename, const void *earg, size_t size,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs if (strcmp(ename, PICLEVENT_SYSEVENT_DEVICE_ADDED) == 0) {
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Check for and add any hotplugged device(s) */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs } else if (strcmp(ename, PICLEVENT_SYSEVENT_DEVICE_REMOVED) == 0) {
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Check for and remove any hotplugged device(s) */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Initializes the FRU nodes for the IO board */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Create the node for the IO board (if it exists) */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs if (ptree_get_node_by_path(platform_frupath[IOBRD], &tmph) ==
1ed830817782694e7259ee818a2f8eee72233f1eMichael Speer err = add_ref_prop(iobrdh, tmph, SEEPROM_SOURCE);
1ed830817782694e7259ee818a2f8eee72233f1eMichael Speer/* Initializes the FRU node for the RSC card */
1ed830817782694e7259ee818a2f8eee72233f1eMichael Speer /* Create the node for the RSC board (if it exists) */
1ed830817782694e7259ee818a2f8eee72233f1eMichael Speer if (ptree_get_node_by_path(platform_frupath[RSC], &tmph) ==
1ed830817782694e7259ee818a2f8eee72233f1eMichael Speer err = ptree_create_node("rsc-board", "fru", &rscbrdh);
1ed830817782694e7259ee818a2f8eee72233f1eMichael Speer err = add_ref_prop(rscbrdh, tmph, SEEPROM_SOURCE);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Initializes the FRU nodes for the FCAL backplaned */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Create the node for the FCAL backplane slot */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* If the FCAL backplane exists, create a node for it */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs if (ptree_get_node_by_path(platform_frupath[DISKBACKPLANE], &tmph) ==
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Initializes the FRU nodes for the PDB and the power supplies */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Create the node for the PDB (if it exists) */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs if (ptree_get_node_by_path(platform_frupath[PDB], &tmph) ==
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_create_node("power-dist-board", "fru", &powerbrdh);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Create the node for the power supply slot */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* If the PS exists, create a node for it */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Initializes the FRU nodes for the centerplane and CPU Memory modules */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Create the node for the system board (if it exists) */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs if (ptree_get_node_by_path(platform_frupath[CENTERPLANE], &tmph) ==
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Create the node for the CPU Memory slot */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* If CPU Mem module exists, create a node for it */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Creates the FRU nodes for the CPU Module and associated DIMMs */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs for (i = 0; i <= 1; i++) {
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Create the nodes for the memory (if they exist) */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Creates the FRU nodes for the DIMMs on a particular CPU Module */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs for (i = 0; i < DIMMS_PER_MOD; i++) {
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Create the node for the memory slot */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* If the memory module exists, create a node for it */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs if (ptree_get_node_by_path(platform_frupath[c], &tmph) ==
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Creates a "reference" property between two PICL nodes */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsadd_ref_prop(picl_nodehdl_t nodeh, picl_nodehdl_t tmph, char *str)
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_init_propinfo(&propinfo, PTREE_PROPINFO_VERSION,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs PICL_PTYPE_REFERENCE, PICL_READ, sizeof (picl_nodehdl_t),
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_create_and_add_prop(nodeh, &propinfo, &tmph, &proph);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Creates a "slot" property for a given PICL node */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_init_propinfo(&propinfo, PTREE_PROPINFO_VERSION,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_create_and_add_prop(nodeh, &propinfo, &slotnum, &proph);
1ed830817782694e7259ee818a2f8eee72233f1eMichael Speer/* Creates a "Label" property for a given PICL node */
1ed830817782694e7259ee818a2f8eee72233f1eMichael Speeradd_label_prop(picl_nodehdl_t nodeh, char *label)
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_init_propinfo(&propinfo, PTREE_PROPINFO_VERSION,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs PICL_PTYPE_CHARSTRING, PICL_READ, strlen(label)+1, "Label",
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_create_and_add_prop(nodeh, &propinfo, label, &proph);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Creates a "FRUDataAvailable" void property for the given PICL node */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_init_propinfo(&propinfo, PTREE_PROPINFO_VERSION,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs PICL_PTYPE_VOID, PICL_READ, 0, "FRUDataAvailable", NULL, NULL);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_create_and_add_prop(nodeh, &propinfo, NULL, &proph);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Creates a "ViewPoints" property -- used for chassis */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_init_propinfo(&propinfo, PTREE_PROPINFO_VERSION,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs PICL_PTYPE_CHARSTRING, PICL_READ, strlen(string)+1, "ViewPoints",
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_create_and_add_prop(nodeh, &propinfo, string, &proph);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Creates and adds all of the frutree nodes */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Get the root node of the PICL tree */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Create and add the root node of the FRU subtree */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_create_and_add_node(rooth, "frutree", "picl", &frutreeh);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Create and add the chassis node */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_create_and_add_node(frutreeh, "chassis", "fru", &chassish);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Add ViewPoints prop to chassis node */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Initialize the FRU nodes for the IO board */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Initialize the FRU node for the RSC card */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Initialize the FRU nodes for the DISK backplane */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Initialize the FRU nodes for the PDB and the power supplies */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Initialize the FRU nodes for the CPU Memory modules */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Deletes and destroys all PICL nodes for which rooth is a ancestor */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs while (!done) {
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_get_propval_by_name(rooth, PICL_PROP_CHILD, &chdh,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Searches the list of hotpluggable FRUs, adds the appropriate node(s) */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Check for hotplugged power supplies */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Compare the /platform tree to the frutree */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* If they are different, then add a power supply */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Searches the list of hotpluggable FRUs, removes the appropriate node(s) */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Check for hotplugged power supplies */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Compare the /platform tree to the frutree */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* If they are different, then remove a power supply */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Compare the /platform tree to the /frutree to determine if a
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * new device has been added
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Check for node in the /platform tree */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * The node is in /platform, so find the corresponding slot in
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * the frutree
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * If the slot in the frutree has a child, then return
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * PICL_FAILURE. This means that the /platform tree and
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * the frutree are consistent and no action is necessary.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Otherwise return PICL_SUCCESS to indicate that a node needs
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * to be added to the frutree
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_get_propval_by_name(frusloth, PICL_PROP_CHILD,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Compare the /platform tree to the /frutree to determine if a
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * device has been removed
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Check for node in /platform tree */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * The node is not in /platform, so find the corresponding slot in
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * the frutree
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * If the slot in the frutree does not have a child, then return
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * PICL_FAILURE. This means that the /platform tree and
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * the frutree are consistent and no action is necessary.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Otherwise return PICL_SUCCESS to indicate that the needs
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * to be removed from the frutree
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_get_propval_by_name(frusloth, PICL_PROP_CHILD,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* event completion handler for PICL_FRU_ADDED/PICL_FRU_REMOVED events */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic void
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsfrudr_completion_handler(char *ename, void *earg, size_t size)
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * now frudata has been notified that the node is to be
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * removed, we can actually remove it
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Post the PICL_FRU_ADDED/PICL_FRU_REMOVED event
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsstatic void
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qspost_frudr_event(char *ename, picl_nodehdl_t parenth, picl_nodehdl_t fruh)
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs if (parenth != 0L &&
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs nvlist_add_uint64(nvl, PICLEVENTARG_PARENTHANDLE, parenth)) {
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs if (fruh != 0L &&
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Hotplug routine used to add a new power supply */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Find the node for the given power supply slot */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs if (ptree_get_node_by_path(frutree_power_supply[slotnum],
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Make sure it's in /platform and create the frutree node */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs if (ptree_get_node_by_path(platform_frupath[i], &tmph) ==
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Post picl-fru-added event */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Hotplug routine used to remove an existing power supply */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Find the node for the given power supply slot */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs if (ptree_get_node_by_path(frutree_power_supply[slotnum],
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Make sure it's got a child, then delete it */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs err = ptree_get_propval_by_name(powersloth, PICL_PROP_CHILD,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* Post picl-fru-removed event */