19160SSherry.Moore@Sun.COM /*
29160SSherry.Moore@Sun.COM  * CDDL HEADER START
39160SSherry.Moore@Sun.COM  *
49160SSherry.Moore@Sun.COM  * The contents of this file are subject to the terms of the
59160SSherry.Moore@Sun.COM  * Common Development and Distribution License (the "License").
69160SSherry.Moore@Sun.COM  * You may not use this file except in compliance with the License.
79160SSherry.Moore@Sun.COM  *
89160SSherry.Moore@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
99160SSherry.Moore@Sun.COM  * or http://www.opensolaris.org/os/licensing.
109160SSherry.Moore@Sun.COM  * See the License for the specific language governing permissions
119160SSherry.Moore@Sun.COM  * and limitations under the License.
129160SSherry.Moore@Sun.COM  *
139160SSherry.Moore@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
149160SSherry.Moore@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
159160SSherry.Moore@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
169160SSherry.Moore@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
179160SSherry.Moore@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
189160SSherry.Moore@Sun.COM  *
199160SSherry.Moore@Sun.COM  * CDDL HEADER END
209160SSherry.Moore@Sun.COM  */
219160SSherry.Moore@Sun.COM 
229160SSherry.Moore@Sun.COM /*
239160SSherry.Moore@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
249160SSherry.Moore@Sun.COM  * Use is subject to license terms.
259160SSherry.Moore@Sun.COM  */
269160SSherry.Moore@Sun.COM 
279160SSherry.Moore@Sun.COM /*
289160SSherry.Moore@Sun.COM  * This file contains high level functions used by multiple utilities.
299160SSherry.Moore@Sun.COM  */
309160SSherry.Moore@Sun.COM 
319160SSherry.Moore@Sun.COM #include "libscf_impl.h"
329160SSherry.Moore@Sun.COM 
339160SSherry.Moore@Sun.COM #include <assert.h>
349160SSherry.Moore@Sun.COM #include <libuutil.h>
359160SSherry.Moore@Sun.COM #include <string.h>
369160SSherry.Moore@Sun.COM #include <stdlib.h>
379160SSherry.Moore@Sun.COM #include <sys/systeminfo.h>
389160SSherry.Moore@Sun.COM #include <sys/uadmin.h>
399160SSherry.Moore@Sun.COM #include <sys/utsname.h>
409160SSherry.Moore@Sun.COM 
419160SSherry.Moore@Sun.COM #ifdef	__x86
429160SSherry.Moore@Sun.COM #include <smbios.h>
439160SSherry.Moore@Sun.COM 
449160SSherry.Moore@Sun.COM /*
459160SSherry.Moore@Sun.COM  * Check whether the platform is on the fastreboot_blacklist.
469160SSherry.Moore@Sun.COM  * Return 1 if the platform has been blacklisted, 0 otherwise.
479160SSherry.Moore@Sun.COM  */
489160SSherry.Moore@Sun.COM static int
499160SSherry.Moore@Sun.COM scf_is_fb_blacklisted(void)
509160SSherry.Moore@Sun.COM {
519160SSherry.Moore@Sun.COM 	smbios_hdl_t *shp;
529160SSherry.Moore@Sun.COM 	smbios_system_t sys;
539160SSherry.Moore@Sun.COM 	smbios_info_t info;
549160SSherry.Moore@Sun.COM 
559160SSherry.Moore@Sun.COM 	id_t id;
569160SSherry.Moore@Sun.COM 	int err;
579160SSherry.Moore@Sun.COM 	int i;
589160SSherry.Moore@Sun.COM 
599160SSherry.Moore@Sun.COM 	scf_simple_prop_t *prop = NULL;
609160SSherry.Moore@Sun.COM 	ssize_t numvals;
619160SSherry.Moore@Sun.COM 	char *platform_name;
629160SSherry.Moore@Sun.COM 
639160SSherry.Moore@Sun.COM 	int blacklisted = 0;
649160SSherry.Moore@Sun.COM 
659160SSherry.Moore@Sun.COM 	/*
669160SSherry.Moore@Sun.COM 	 * If there's no SMBIOS, assume it's blacklisted.
679160SSherry.Moore@Sun.COM 	 */
689160SSherry.Moore@Sun.COM 	if ((shp = smbios_open(NULL, SMB_VERSION, 0, &err)) == NULL)
699160SSherry.Moore@Sun.COM 		return (1);
709160SSherry.Moore@Sun.COM 
719160SSherry.Moore@Sun.COM 	/*
729160SSherry.Moore@Sun.COM 	 * If we can't read system info, assume it's blacklisted.
739160SSherry.Moore@Sun.COM 	 */
749160SSherry.Moore@Sun.COM 	if ((id = smbios_info_system(shp, &sys)) == SMB_ERR ||
759160SSherry.Moore@Sun.COM 	    smbios_info_common(shp, id, &info) == SMB_ERR) {
769160SSherry.Moore@Sun.COM 		blacklisted = 1;
779160SSherry.Moore@Sun.COM 		goto fb_out;
789160SSherry.Moore@Sun.COM 	}
799160SSherry.Moore@Sun.COM 
809160SSherry.Moore@Sun.COM 	/*
819160SSherry.Moore@Sun.COM 	 * If we can't read the "platforms" property from property group
829160SSherry.Moore@Sun.COM 	 * BOOT_CONFIG_PG_FBBLACKLIST, assume no platforms have
839160SSherry.Moore@Sun.COM 	 * been blacklisted.
849160SSherry.Moore@Sun.COM 	 */
859160SSherry.Moore@Sun.COM 	if ((prop = scf_simple_prop_get(NULL, FMRI_BOOT_CONFIG,
869160SSherry.Moore@Sun.COM 	    BOOT_CONFIG_PG_FBBLACKLIST, "platforms")) == NULL)
879160SSherry.Moore@Sun.COM 		goto fb_out;
889160SSherry.Moore@Sun.COM 
899160SSherry.Moore@Sun.COM 	numvals = scf_simple_prop_numvalues(prop);
909160SSherry.Moore@Sun.COM 
919160SSherry.Moore@Sun.COM 	for (i = 0; i < numvals; i++) {
929160SSherry.Moore@Sun.COM 		platform_name = scf_simple_prop_next_astring(prop);
939160SSherry.Moore@Sun.COM 		if (platform_name == NULL)
949160SSherry.Moore@Sun.COM 			break;
959160SSherry.Moore@Sun.COM 		if (strcmp(platform_name, info.smbi_product) == 0) {
969160SSherry.Moore@Sun.COM 			blacklisted = 1;
979160SSherry.Moore@Sun.COM 			break;
989160SSherry.Moore@Sun.COM 		}
999160SSherry.Moore@Sun.COM 	}
1009160SSherry.Moore@Sun.COM 
1019160SSherry.Moore@Sun.COM fb_out:
1029160SSherry.Moore@Sun.COM 	smbios_close(shp);
1039160SSherry.Moore@Sun.COM 	scf_simple_prop_free(prop);
1049160SSherry.Moore@Sun.COM 
1059160SSherry.Moore@Sun.COM 	return (blacklisted);
1069160SSherry.Moore@Sun.COM }
107*9862SSherry.Moore@Sun.COM 
108*9862SSherry.Moore@Sun.COM /*
109*9862SSherry.Moore@Sun.COM  * Add or get a property group given an FMRI.
110*9862SSherry.Moore@Sun.COM  * Return SCF_SUCCESS on success, SCF_FAILED on failure.
111*9862SSherry.Moore@Sun.COM  */
112*9862SSherry.Moore@Sun.COM static int
113*9862SSherry.Moore@Sun.COM scf_fmri_pg_get_or_add(const char *fmri, const char *pgname,
114*9862SSherry.Moore@Sun.COM     const char *pgtype, uint32_t pgflags, int add)
115*9862SSherry.Moore@Sun.COM {
116*9862SSherry.Moore@Sun.COM 	scf_handle_t	*handle = NULL;
117*9862SSherry.Moore@Sun.COM 	scf_instance_t	*inst = NULL;
118*9862SSherry.Moore@Sun.COM 	int		rc = SCF_FAILED;
119*9862SSherry.Moore@Sun.COM 	int		error = SCF_ERROR_NONE;
120*9862SSherry.Moore@Sun.COM 
121*9862SSherry.Moore@Sun.COM 	if ((handle = scf_handle_create(SCF_VERSION)) == NULL ||
122*9862SSherry.Moore@Sun.COM 	    scf_handle_bind(handle) != 0 ||
123*9862SSherry.Moore@Sun.COM 	    (inst = scf_instance_create(handle)) == NULL ||
124*9862SSherry.Moore@Sun.COM 	    scf_handle_decode_fmri(handle, fmri, NULL, NULL,
125*9862SSherry.Moore@Sun.COM 	    inst, NULL, NULL, SCF_DECODE_FMRI_EXACT) != SCF_SUCCESS)
126*9862SSherry.Moore@Sun.COM 		goto scferror;
127*9862SSherry.Moore@Sun.COM 
128*9862SSherry.Moore@Sun.COM 	if (add) {
129*9862SSherry.Moore@Sun.COM 		rc = scf_instance_add_pg(inst, pgname, pgtype, pgflags, NULL);
130*9862SSherry.Moore@Sun.COM 		/*
131*9862SSherry.Moore@Sun.COM 		 * If the property group already exists, return SCF_SUCCESS.
132*9862SSherry.Moore@Sun.COM 		 */
133*9862SSherry.Moore@Sun.COM 		if (rc != SCF_SUCCESS && scf_error() == SCF_ERROR_EXISTS) {
134*9862SSherry.Moore@Sun.COM 			(void) scf_set_error(SCF_ERROR_NONE);
135*9862SSherry.Moore@Sun.COM 			rc = SCF_SUCCESS;
136*9862SSherry.Moore@Sun.COM 		}
137*9862SSherry.Moore@Sun.COM 	} else {
138*9862SSherry.Moore@Sun.COM 		rc = scf_instance_get_pg(inst, pgname, NULL);
139*9862SSherry.Moore@Sun.COM 	}
140*9862SSherry.Moore@Sun.COM 
141*9862SSherry.Moore@Sun.COM scferror:
142*9862SSherry.Moore@Sun.COM 	error = scf_error();
143*9862SSherry.Moore@Sun.COM 
144*9862SSherry.Moore@Sun.COM 	scf_instance_destroy(inst);
145*9862SSherry.Moore@Sun.COM 	if (handle)
146*9862SSherry.Moore@Sun.COM 		(void) scf_handle_unbind(handle);
147*9862SSherry.Moore@Sun.COM 	scf_handle_destroy(handle);
148*9862SSherry.Moore@Sun.COM 
149*9862SSherry.Moore@Sun.COM 	if (error != SCF_ERROR_NONE) {
150*9862SSherry.Moore@Sun.COM 		(void) scf_set_error(error);
151*9862SSherry.Moore@Sun.COM 		rc = SCF_FAILED;
152*9862SSherry.Moore@Sun.COM 	}
153*9862SSherry.Moore@Sun.COM 	return (rc);
154*9862SSherry.Moore@Sun.COM }
1559160SSherry.Moore@Sun.COM #endif	/* __x86 */
1569160SSherry.Moore@Sun.COM 
1579160SSherry.Moore@Sun.COM /*
1589160SSherry.Moore@Sun.COM  * Get config properties from svc:/system/boot-config:default.
1599160SSherry.Moore@Sun.COM  * It prints errors with uu_warn().
1609160SSherry.Moore@Sun.COM  */
1619160SSherry.Moore@Sun.COM void
1629160SSherry.Moore@Sun.COM scf_get_boot_config(uint8_t *boot_config)
1639160SSherry.Moore@Sun.COM {
1649160SSherry.Moore@Sun.COM 	assert(boot_config);
1659160SSherry.Moore@Sun.COM 	*boot_config = 0;
1669160SSherry.Moore@Sun.COM 
1679160SSherry.Moore@Sun.COM #ifndef	__x86
1689160SSherry.Moore@Sun.COM 	return;
1699160SSherry.Moore@Sun.COM #else
1709160SSherry.Moore@Sun.COM 	{
1719160SSherry.Moore@Sun.COM 		/*
1729160SSherry.Moore@Sun.COM 		 * Property vector for BOOT_CONFIG_PG_PARAMS property group.
1739160SSherry.Moore@Sun.COM 		 */
1749160SSherry.Moore@Sun.COM 		scf_propvec_t ua_boot_config[] = {
175*9862SSherry.Moore@Sun.COM 			{ FASTREBOOT_DEFAULT, NULL, SCF_TYPE_BOOLEAN, NULL,
1769160SSherry.Moore@Sun.COM 			    UA_FASTREBOOT_DEFAULT },
1779160SSherry.Moore@Sun.COM 			{ FASTREBOOT_ONPANIC, NULL, SCF_TYPE_BOOLEAN, NULL,
1789160SSherry.Moore@Sun.COM 			    UA_FASTREBOOT_ONPANIC },
1799160SSherry.Moore@Sun.COM 			{ NULL }
1809160SSherry.Moore@Sun.COM 		};
1819160SSherry.Moore@Sun.COM 		scf_propvec_t	*prop;
1829160SSherry.Moore@Sun.COM 
1839160SSherry.Moore@Sun.COM 		for (prop = ua_boot_config; prop->pv_prop != NULL; prop++)
1849160SSherry.Moore@Sun.COM 			prop->pv_ptr = boot_config;
1859160SSherry.Moore@Sun.COM 		prop = NULL;
1869160SSherry.Moore@Sun.COM 		if (scf_read_propvec(FMRI_BOOT_CONFIG, BOOT_CONFIG_PG_PARAMS,
1879160SSherry.Moore@Sun.COM 		    B_TRUE, ua_boot_config, &prop) != SCF_FAILED) {
1889160SSherry.Moore@Sun.COM 			/*
1899160SSherry.Moore@Sun.COM 			 * Unset both flags if the platform has been
1909160SSherry.Moore@Sun.COM 			 * blacklisted.
1919160SSherry.Moore@Sun.COM 			 */
1929160SSherry.Moore@Sun.COM 			if (scf_is_fb_blacklisted())
1939160SSherry.Moore@Sun.COM 				*boot_config &= ~(UA_FASTREBOOT_DEFAULT |
1949160SSherry.Moore@Sun.COM 				    UA_FASTREBOOT_ONPANIC);
1959160SSherry.Moore@Sun.COM 			return;
1969160SSherry.Moore@Sun.COM 		}
1979160SSherry.Moore@Sun.COM #if defined(FASTREBOOT_DEBUG)
1989160SSherry.Moore@Sun.COM 		if (prop != NULL) {
1999160SSherry.Moore@Sun.COM 			(void) uu_warn("Service %s property '%s/%s' "
2009160SSherry.Moore@Sun.COM 			    "not found.\n", FMRI_BOOT_CONFIG,
2019160SSherry.Moore@Sun.COM 			    BOOT_CONFIG_PG_PARAMS, prop->pv_prop);
2029160SSherry.Moore@Sun.COM 		} else {
2039160SSherry.Moore@Sun.COM 			(void) uu_warn("Unable to read service %s "
2049160SSherry.Moore@Sun.COM 			    "property '%s': %s\n", FMRI_BOOT_CONFIG,
2059160SSherry.Moore@Sun.COM 			    BOOT_CONFIG_PG_PARAMS, scf_strerror(scf_error()));
2069160SSherry.Moore@Sun.COM 		}
2079160SSherry.Moore@Sun.COM #endif	/* FASTREBOOT_DEBUG */
2089160SSherry.Moore@Sun.COM 	}
2099160SSherry.Moore@Sun.COM #endif	/* __x86 */
2109160SSherry.Moore@Sun.COM }
2119160SSherry.Moore@Sun.COM 
2129160SSherry.Moore@Sun.COM /*
213*9862SSherry.Moore@Sun.COM  * Get or set properties in non-persistent "config_ovr" property group
214*9862SSherry.Moore@Sun.COM  * in svc:/system/boot-config:default.
215*9862SSherry.Moore@Sun.COM  * It prints errors with uu_warn().
216*9862SSherry.Moore@Sun.COM  */
217*9862SSherry.Moore@Sun.COM /*ARGSUSED*/
218*9862SSherry.Moore@Sun.COM static int
219*9862SSherry.Moore@Sun.COM scf_getset_boot_config_ovr(int set, uint8_t *boot_config_ovr)
220*9862SSherry.Moore@Sun.COM {
221*9862SSherry.Moore@Sun.COM 	int rc = SCF_SUCCESS;
222*9862SSherry.Moore@Sun.COM 
223*9862SSherry.Moore@Sun.COM 	assert(boot_config_ovr);
224*9862SSherry.Moore@Sun.COM 
225*9862SSherry.Moore@Sun.COM #ifndef	__x86
226*9862SSherry.Moore@Sun.COM 	return (rc);
227*9862SSherry.Moore@Sun.COM #else
228*9862SSherry.Moore@Sun.COM 	{
229*9862SSherry.Moore@Sun.COM 		/*
230*9862SSherry.Moore@Sun.COM 		 * Property vector for BOOT_CONFIG_PG_OVR property group.
231*9862SSherry.Moore@Sun.COM 		 */
232*9862SSherry.Moore@Sun.COM 		scf_propvec_t ua_boot_config_ovr[] = {
233*9862SSherry.Moore@Sun.COM 			{ FASTREBOOT_DEFAULT, NULL, SCF_TYPE_BOOLEAN, NULL,
234*9862SSherry.Moore@Sun.COM 			    UA_FASTREBOOT_DEFAULT },
235*9862SSherry.Moore@Sun.COM 			{ NULL }
236*9862SSherry.Moore@Sun.COM 		};
237*9862SSherry.Moore@Sun.COM 		scf_propvec_t	*prop;
238*9862SSherry.Moore@Sun.COM 
239*9862SSherry.Moore@Sun.COM 		rc = scf_fmri_pg_get_or_add(FMRI_BOOT_CONFIG,
240*9862SSherry.Moore@Sun.COM 		    BOOT_CONFIG_PG_OVR, SCF_GROUP_APPLICATION,
241*9862SSherry.Moore@Sun.COM 		    SCF_PG_FLAG_NONPERSISTENT, set);
242*9862SSherry.Moore@Sun.COM 
243*9862SSherry.Moore@Sun.COM 		if (rc != SCF_SUCCESS) {
244*9862SSherry.Moore@Sun.COM #if defined(FASTREBOOT_DEBUG)
245*9862SSherry.Moore@Sun.COM 			if (set)
246*9862SSherry.Moore@Sun.COM 				(void) uu_warn("Unable to add service %s "
247*9862SSherry.Moore@Sun.COM 				    "property group '%s'\n",
248*9862SSherry.Moore@Sun.COM 				    FMRI_BOOT_CONFIG, BOOT_CONFIG_PG_OVR);
249*9862SSherry.Moore@Sun.COM #endif	/* FASTREBOOT_DEBUG */
250*9862SSherry.Moore@Sun.COM 			return (rc);
251*9862SSherry.Moore@Sun.COM 		}
252*9862SSherry.Moore@Sun.COM 
253*9862SSherry.Moore@Sun.COM 		for (prop = ua_boot_config_ovr; prop->pv_prop != NULL; prop++)
254*9862SSherry.Moore@Sun.COM 			prop->pv_ptr = boot_config_ovr;
255*9862SSherry.Moore@Sun.COM 		prop = NULL;
256*9862SSherry.Moore@Sun.COM 
257*9862SSherry.Moore@Sun.COM 		if (set)
258*9862SSherry.Moore@Sun.COM 			rc = scf_write_propvec(FMRI_BOOT_CONFIG,
259*9862SSherry.Moore@Sun.COM 			    BOOT_CONFIG_PG_OVR, ua_boot_config_ovr, &prop);
260*9862SSherry.Moore@Sun.COM 		else
261*9862SSherry.Moore@Sun.COM 			rc = scf_read_propvec(FMRI_BOOT_CONFIG,
262*9862SSherry.Moore@Sun.COM 			    BOOT_CONFIG_PG_OVR, B_FALSE, ua_boot_config_ovr,
263*9862SSherry.Moore@Sun.COM 			    &prop);
264*9862SSherry.Moore@Sun.COM 
265*9862SSherry.Moore@Sun.COM #if defined(FASTREBOOT_DEBUG)
266*9862SSherry.Moore@Sun.COM 		if (rc != SCF_SUCCESS) {
267*9862SSherry.Moore@Sun.COM 			if (prop != NULL) {
268*9862SSherry.Moore@Sun.COM 				(void) uu_warn("Service %s property '%s/%s' "
269*9862SSherry.Moore@Sun.COM 				    "not found.\n", FMRI_BOOT_CONFIG,
270*9862SSherry.Moore@Sun.COM 				    BOOT_CONFIG_PG_OVR, prop->pv_prop);
271*9862SSherry.Moore@Sun.COM 			} else {
272*9862SSherry.Moore@Sun.COM 				(void) uu_warn("Unable to %s service %s "
273*9862SSherry.Moore@Sun.COM 				    "property '%s': %s\n", set ? "set" : "get",
274*9862SSherry.Moore@Sun.COM 				    FMRI_BOOT_CONFIG, BOOT_CONFIG_PG_OVR,
275*9862SSherry.Moore@Sun.COM 				    scf_strerror(scf_error()));
276*9862SSherry.Moore@Sun.COM 			}
277*9862SSherry.Moore@Sun.COM 		}
278*9862SSherry.Moore@Sun.COM #endif	/* FASTREBOOT_DEBUG */
279*9862SSherry.Moore@Sun.COM 		return (rc);
280*9862SSherry.Moore@Sun.COM 
281*9862SSherry.Moore@Sun.COM 	}
282*9862SSherry.Moore@Sun.COM #endif	/* __x86 */
283*9862SSherry.Moore@Sun.COM }
284*9862SSherry.Moore@Sun.COM 
285*9862SSherry.Moore@Sun.COM /*
286*9862SSherry.Moore@Sun.COM  * Get values of properties in non-persistent "config_ovr" property group.
287*9862SSherry.Moore@Sun.COM  */
288*9862SSherry.Moore@Sun.COM static void
289*9862SSherry.Moore@Sun.COM scf_get_boot_config_ovr(uint8_t *boot_config_ovr)
290*9862SSherry.Moore@Sun.COM {
291*9862SSherry.Moore@Sun.COM 	(void) scf_getset_boot_config_ovr(B_FALSE, boot_config_ovr);
292*9862SSherry.Moore@Sun.COM }
293*9862SSherry.Moore@Sun.COM 
294*9862SSherry.Moore@Sun.COM /*
295*9862SSherry.Moore@Sun.COM  * Set value of "config_ovr/fastreboot_default".
296*9862SSherry.Moore@Sun.COM  */
297*9862SSherry.Moore@Sun.COM int
298*9862SSherry.Moore@Sun.COM scf_fastreboot_default_set_transient(boolean_t value)
299*9862SSherry.Moore@Sun.COM {
300*9862SSherry.Moore@Sun.COM 	uint8_t	boot_config_ovr = (value & UA_FASTREBOOT_DEFAULT);
301*9862SSherry.Moore@Sun.COM 
302*9862SSherry.Moore@Sun.COM 	return (scf_getset_boot_config_ovr(B_TRUE, &boot_config_ovr));
303*9862SSherry.Moore@Sun.COM }
304*9862SSherry.Moore@Sun.COM 
305*9862SSherry.Moore@Sun.COM /*
3069160SSherry.Moore@Sun.COM  * Check whether Fast Reboot is the default operating mode.
3079160SSherry.Moore@Sun.COM  * Return 0 if
3089160SSherry.Moore@Sun.COM  *   1. the platform is xVM
3099160SSherry.Moore@Sun.COM  * or
3109160SSherry.Moore@Sun.COM  *   2. svc:/system/boot-config:default service doesn't exist,
3119160SSherry.Moore@Sun.COM  * or
312*9862SSherry.Moore@Sun.COM  *   3. property "config/fastreboot_default" doesn't exist,
3139160SSherry.Moore@Sun.COM  * or
314*9862SSherry.Moore@Sun.COM  *   4. value of property "config/fastreboot_default" is set to "false"
315*9862SSherry.Moore@Sun.COM  *      and "config_ovr/fastreboot_default" is not set to "true",
3169160SSherry.Moore@Sun.COM  * or
3179160SSherry.Moore@Sun.COM  *   5. the platform has been blacklisted.
318*9862SSherry.Moore@Sun.COM  * or
319*9862SSherry.Moore@Sun.COM  *   6. value of property "config_ovr/fastreboot_default" is set to "false".
3209160SSherry.Moore@Sun.COM  * Return non-zero otherwise.
3219160SSherry.Moore@Sun.COM  */
3229160SSherry.Moore@Sun.COM int
3239160SSherry.Moore@Sun.COM scf_is_fastboot_default(void)
3249160SSherry.Moore@Sun.COM {
325*9862SSherry.Moore@Sun.COM 	uint8_t	boot_config = 0, boot_config_ovr;
3269160SSherry.Moore@Sun.COM 	char procbuf[SYS_NMLN];
3279160SSherry.Moore@Sun.COM 
3289160SSherry.Moore@Sun.COM 	/*
3299160SSherry.Moore@Sun.COM 	 * If we are on xVM, do not fast reboot by default.
3309160SSherry.Moore@Sun.COM 	 */
3319160SSherry.Moore@Sun.COM 	if (sysinfo(SI_PLATFORM, procbuf, sizeof (procbuf)) == -1 ||
3329160SSherry.Moore@Sun.COM 	    strcmp(procbuf, "i86xpv") == 0)
3339160SSherry.Moore@Sun.COM 		return (0);
3349160SSherry.Moore@Sun.COM 
335*9862SSherry.Moore@Sun.COM 	/*
336*9862SSherry.Moore@Sun.COM 	 * Get property values from "config" property group
337*9862SSherry.Moore@Sun.COM 	 */
3389160SSherry.Moore@Sun.COM 	scf_get_boot_config(&boot_config);
339*9862SSherry.Moore@Sun.COM 
340*9862SSherry.Moore@Sun.COM 	/*
341*9862SSherry.Moore@Sun.COM 	 * Get property values from non-persistent "config_ovr" property group
342*9862SSherry.Moore@Sun.COM 	 */
343*9862SSherry.Moore@Sun.COM 	boot_config_ovr = boot_config;
344*9862SSherry.Moore@Sun.COM 	scf_get_boot_config_ovr(&boot_config_ovr);
345*9862SSherry.Moore@Sun.COM 
346*9862SSherry.Moore@Sun.COM 	return (boot_config & boot_config_ovr & UA_FASTREBOOT_DEFAULT);
3479160SSherry.Moore@Sun.COM }
348