4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * PICL Littleneck platform plug-in to create environment tree nodes.
32 #define _POSIX_PRIORITY_SCHEDULING 1
46 #include <semaphore.h>
49 #include <sys/types.h>
50 #include <sys/systeminfo.h>
51 #include <psvc_objects.h>
53 static psvc_opaque_t hdlp
;
55 #define PSVC_PLUGIN_VERSION PICLD_PLUGIN_VERSION_1
57 #pragma init(psvc_psr_plugin_register) /* place in .init section */
64 extern struct handle
{
70 void psvc_psr_plugin_init(void);
71 void psvc_psr_plugin_fini(void);
73 picld_plugin_reg_t psvc_psr_reg
= {
75 PICLD_PLUGIN_CRITICAL
,
81 #define PSVC_INIT_ERR gettext("%s: Error in psvc_init(): %s\n")
82 #define PTREE_DELETE_NODE_ERR gettext("%s: ptree_delete_node() failed: %s\n")
83 #define PTREE_GET_NODE_ERR \
84 gettext("%s: ptree_get_node_by_path() failed: %s\n")
86 extern int ptree_get_node_by_path(const char *, picl_nodehdl_t
*);
92 {"/SYSTEM/CPU0_MOD_CARD",
93 "/devices/pci@8,700000/ebus@5/i2c@1,30/temperature@0,30:die_temp"},
94 {"/SYSTEM/CPU1_MOD_CARD",
95 "/devices/pci@8,700000/ebus@5/i2c@1,30/temperature@0,98:die_temp"},
96 {"/SYSTEM/AT24C64_A0_1",
97 "/devices/pci@8,700000/ebus@5/i2c@1,2e/dimm@1,a0:dimm"},
98 {"/SYSTEM/AT24C64_A2_1",
99 "/devices/pci@8,700000/ebus@5/i2c@1,2e/dimm@1,a2:dimm"},
100 {"/SYSTEM/AT24C64_A4_1",
101 "/devices/pci@8,700000/ebus@5/i2c@1,2e/dimm@1,a4:dimm"},
102 {"/SYSTEM/AT24C64_A6_1",
103 "/devices/pci@8,700000/ebus@5/i2c@1,2e/dimm@1,a6:dimm"},
104 {"/SYSTEM/AT24C64_A8_1",
105 "/devices/pci@8,700000/ebus@5/i2c@1,2e/dimm@1,a8:dimm"},
106 {"/SYSTEM/AT24C64_AA_1",
107 "/devices/pci@8,700000/ebus@5/i2c@1,2e/dimm@1,aa:dimm"},
108 {"/SYSTEM/AT24C64_AC_1",
109 "/devices/pci@8,700000/ebus@5/i2c@1,2e/dimm@1,ac:dimm"},
110 {"/SYSTEM/AT24C64_AE_1",
111 "/devices/pci@8,700000/ebus@5/i2c@1,2e/dimm@1,ae:dimm"}
113 #define DEV_PR_COUNT (sizeof (dev_pr_info) / sizeof (struct node_file))
115 static void init_err(char *fmt
, char *arg1
, char *arg2
)
119 sprintf(msg
, fmt
, arg1
, arg2
);
120 syslog(LOG_ERR
, msg
);
124 psvc_psr_plugin_init(void)
126 char *funcname
= "psvc_plugin_init";
131 * So the volatile read/write routines can retrieve data from
134 err
= psvc_init(&hdlp
);
136 init_err(PSVC_INIT_ERR
, funcname
, strerror(errno
));
141 * Remove nodes whose devices aren't present from the picl tree.
143 for (i
= 0; i
< psvc_hdl
.obj_count
; ++i
) {
146 objp
= &psvc_hdl
.objects
[i
];
148 err
= psvc_get_attr(hdlp
, objp
->name
, PSVC_PRESENCE_ATTR
,
150 if (err
!= PSVC_SUCCESS
)
152 err
= psvc_get_attr(hdlp
, objp
->name
, PSVC_FEATURES_ATTR
,
154 if (err
!= PSVC_SUCCESS
)
156 if ((features
& (PSVC_DEV_HOTPLUG
| PSVC_DEV_OPTION
)) &&
157 (present
== PSVC_ABSENT
)) {
158 err
= ptree_delete_node(objp
->node
);
160 init_err(PTREE_DELETE_NODE_ERR
, funcname
,
168 * Remove PICL device nodes if their /devices file isn't present or
169 * if the device file is present but the open returns ENXIO
170 * which indicates that the node file doesn't represent a device
171 * tree node and is probably a relic from some previous boot config
173 for (i
= 0; i
< DEV_PR_COUNT
; ++i
) {
174 picl_nodehdl_t dev_pr_node
;
176 fd
= open(dev_pr_info
[i
].file
, O_RDONLY
);
181 if ((errno
!= ENOENT
) && (errno
!= ENXIO
))
184 err
= ptree_get_node_by_path(dev_pr_info
[i
].path
, &dev_pr_node
);
186 init_err(PTREE_GET_NODE_ERR
, funcname
,
191 err
= ptree_delete_node(dev_pr_node
);
193 init_err(PTREE_DELETE_NODE_ERR
, funcname
,
198 free(psvc_hdl
.objects
);
202 psvc_psr_plugin_fini(void)
208 psvc_psr_plugin_register(void)
210 picld_plugin_register(&psvc_psr_reg
);