xref: /onnv-gate/usr/src/lib/libscf/common/highlevel.c (revision 11897:106287105e0f)
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 /*
23*11897SChris.Kiick@Sun.COM  * Copyright 2010 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
scf_is_fb_blacklisted(void)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 }
1079862SSherry.Moore@Sun.COM 
1089862SSherry.Moore@Sun.COM /*
1099862SSherry.Moore@Sun.COM  * Add or get a property group given an FMRI.
1109862SSherry.Moore@Sun.COM  * Return SCF_SUCCESS on success, SCF_FAILED on failure.
1119862SSherry.Moore@Sun.COM  */
1129862SSherry.Moore@Sun.COM static int
scf_fmri_pg_get_or_add(const char * fmri,const char * pgname,const char * pgtype,uint32_t pgflags,int add)1139862SSherry.Moore@Sun.COM scf_fmri_pg_get_or_add(const char *fmri, const char *pgname,
1149862SSherry.Moore@Sun.COM     const char *pgtype, uint32_t pgflags, int add)
1159862SSherry.Moore@Sun.COM {
1169862SSherry.Moore@Sun.COM 	scf_handle_t	*handle = NULL;
1179862SSherry.Moore@Sun.COM 	scf_instance_t	*inst = NULL;
1189862SSherry.Moore@Sun.COM 	int		rc = SCF_FAILED;
11910065SSherry.Moore@Sun.COM 	int		error;
1209862SSherry.Moore@Sun.COM 
1219862SSherry.Moore@Sun.COM 	if ((handle = scf_handle_create(SCF_VERSION)) == NULL ||
1229862SSherry.Moore@Sun.COM 	    scf_handle_bind(handle) != 0 ||
1239862SSherry.Moore@Sun.COM 	    (inst = scf_instance_create(handle)) == NULL ||
1249862SSherry.Moore@Sun.COM 	    scf_handle_decode_fmri(handle, fmri, NULL, NULL,
1259862SSherry.Moore@Sun.COM 	    inst, NULL, NULL, SCF_DECODE_FMRI_EXACT) != SCF_SUCCESS)
1269862SSherry.Moore@Sun.COM 		goto scferror;
1279862SSherry.Moore@Sun.COM 
1289862SSherry.Moore@Sun.COM 	if (add) {
1299862SSherry.Moore@Sun.COM 		rc = scf_instance_add_pg(inst, pgname, pgtype, pgflags, NULL);
1309862SSherry.Moore@Sun.COM 		/*
1319862SSherry.Moore@Sun.COM 		 * If the property group already exists, return SCF_SUCCESS.
1329862SSherry.Moore@Sun.COM 		 */
13310065SSherry.Moore@Sun.COM 		if (rc != SCF_SUCCESS && scf_error() == SCF_ERROR_EXISTS)
1349862SSherry.Moore@Sun.COM 			rc = SCF_SUCCESS;
1359862SSherry.Moore@Sun.COM 	} else {
1369862SSherry.Moore@Sun.COM 		rc = scf_instance_get_pg(inst, pgname, NULL);
1379862SSherry.Moore@Sun.COM 	}
1389862SSherry.Moore@Sun.COM 
1399862SSherry.Moore@Sun.COM scferror:
14010065SSherry.Moore@Sun.COM 	if (rc != SCF_SUCCESS)
14110065SSherry.Moore@Sun.COM 		error = scf_error();
1429862SSherry.Moore@Sun.COM 
1439862SSherry.Moore@Sun.COM 	scf_instance_destroy(inst);
1449862SSherry.Moore@Sun.COM 	if (handle)
1459862SSherry.Moore@Sun.COM 		(void) scf_handle_unbind(handle);
1469862SSherry.Moore@Sun.COM 	scf_handle_destroy(handle);
1479862SSherry.Moore@Sun.COM 
14810065SSherry.Moore@Sun.COM 	if (rc != SCF_SUCCESS)
1499862SSherry.Moore@Sun.COM 		(void) scf_set_error(error);
15010065SSherry.Moore@Sun.COM 
1519862SSherry.Moore@Sun.COM 	return (rc);
1529862SSherry.Moore@Sun.COM }
1539160SSherry.Moore@Sun.COM #endif	/* __x86 */
1549160SSherry.Moore@Sun.COM 
1559160SSherry.Moore@Sun.COM /*
1569160SSherry.Moore@Sun.COM  * Get config properties from svc:/system/boot-config:default.
1579160SSherry.Moore@Sun.COM  * It prints errors with uu_warn().
1589160SSherry.Moore@Sun.COM  */
1599160SSherry.Moore@Sun.COM void
scf_get_boot_config(uint8_t * boot_config)1609160SSherry.Moore@Sun.COM scf_get_boot_config(uint8_t *boot_config)
1619160SSherry.Moore@Sun.COM {
1629160SSherry.Moore@Sun.COM 	assert(boot_config);
1639160SSherry.Moore@Sun.COM 	*boot_config = 0;
1649160SSherry.Moore@Sun.COM 
1659160SSherry.Moore@Sun.COM 	{
1669160SSherry.Moore@Sun.COM 		/*
1679160SSherry.Moore@Sun.COM 		 * Property vector for BOOT_CONFIG_PG_PARAMS property group.
1689160SSherry.Moore@Sun.COM 		 */
1699160SSherry.Moore@Sun.COM 		scf_propvec_t ua_boot_config[] = {
1709862SSherry.Moore@Sun.COM 			{ FASTREBOOT_DEFAULT, NULL, SCF_TYPE_BOOLEAN, NULL,
1719160SSherry.Moore@Sun.COM 			    UA_FASTREBOOT_DEFAULT },
1729160SSherry.Moore@Sun.COM 			{ FASTREBOOT_ONPANIC, NULL, SCF_TYPE_BOOLEAN, NULL,
1739160SSherry.Moore@Sun.COM 			    UA_FASTREBOOT_ONPANIC },
1749160SSherry.Moore@Sun.COM 			{ NULL }
1759160SSherry.Moore@Sun.COM 		};
1769160SSherry.Moore@Sun.COM 		scf_propvec_t	*prop;
1779160SSherry.Moore@Sun.COM 
1789160SSherry.Moore@Sun.COM 		for (prop = ua_boot_config; prop->pv_prop != NULL; prop++)
1799160SSherry.Moore@Sun.COM 			prop->pv_ptr = boot_config;
1809160SSherry.Moore@Sun.COM 		prop = NULL;
1819160SSherry.Moore@Sun.COM 		if (scf_read_propvec(FMRI_BOOT_CONFIG, BOOT_CONFIG_PG_PARAMS,
1829160SSherry.Moore@Sun.COM 		    B_TRUE, ua_boot_config, &prop) != SCF_FAILED) {
183*11897SChris.Kiick@Sun.COM 
184*11897SChris.Kiick@Sun.COM #ifdef	__x86
1859160SSherry.Moore@Sun.COM 			/*
1869160SSherry.Moore@Sun.COM 			 * Unset both flags if the platform has been
1879160SSherry.Moore@Sun.COM 			 * blacklisted.
1889160SSherry.Moore@Sun.COM 			 */
1899160SSherry.Moore@Sun.COM 			if (scf_is_fb_blacklisted())
1909160SSherry.Moore@Sun.COM 				*boot_config &= ~(UA_FASTREBOOT_DEFAULT |
1919160SSherry.Moore@Sun.COM 				    UA_FASTREBOOT_ONPANIC);
192*11897SChris.Kiick@Sun.COM #endif	/* __x86 */
1939160SSherry.Moore@Sun.COM 			return;
1949160SSherry.Moore@Sun.COM 		}
1959160SSherry.Moore@Sun.COM #if defined(FASTREBOOT_DEBUG)
1969160SSherry.Moore@Sun.COM 		if (prop != NULL) {
1979160SSherry.Moore@Sun.COM 			(void) uu_warn("Service %s property '%s/%s' "
1989160SSherry.Moore@Sun.COM 			    "not found.\n", FMRI_BOOT_CONFIG,
1999160SSherry.Moore@Sun.COM 			    BOOT_CONFIG_PG_PARAMS, prop->pv_prop);
2009160SSherry.Moore@Sun.COM 		} else {
2019160SSherry.Moore@Sun.COM 			(void) uu_warn("Unable to read service %s "
2029160SSherry.Moore@Sun.COM 			    "property '%s': %s\n", FMRI_BOOT_CONFIG,
2039160SSherry.Moore@Sun.COM 			    BOOT_CONFIG_PG_PARAMS, scf_strerror(scf_error()));
2049160SSherry.Moore@Sun.COM 		}
2059160SSherry.Moore@Sun.COM #endif	/* FASTREBOOT_DEBUG */
2069160SSherry.Moore@Sun.COM 	}
2079160SSherry.Moore@Sun.COM }
2089160SSherry.Moore@Sun.COM 
2099160SSherry.Moore@Sun.COM /*
2109862SSherry.Moore@Sun.COM  * Get or set properties in non-persistent "config_ovr" property group
2119862SSherry.Moore@Sun.COM  * in svc:/system/boot-config:default.
2129862SSherry.Moore@Sun.COM  * It prints errors with uu_warn().
2139862SSherry.Moore@Sun.COM  */
2149862SSherry.Moore@Sun.COM /*ARGSUSED*/
2159862SSherry.Moore@Sun.COM static int
scf_getset_boot_config_ovr(int set,uint8_t * boot_config_ovr)2169862SSherry.Moore@Sun.COM scf_getset_boot_config_ovr(int set, uint8_t *boot_config_ovr)
2179862SSherry.Moore@Sun.COM {
2189862SSherry.Moore@Sun.COM 	int rc = SCF_SUCCESS;
2199862SSherry.Moore@Sun.COM 
2209862SSherry.Moore@Sun.COM 	assert(boot_config_ovr);
2219862SSherry.Moore@Sun.COM 
2229862SSherry.Moore@Sun.COM #ifndef	__x86
2239862SSherry.Moore@Sun.COM 	return (rc);
2249862SSherry.Moore@Sun.COM #else
2259862SSherry.Moore@Sun.COM 	{
2269862SSherry.Moore@Sun.COM 		/*
2279862SSherry.Moore@Sun.COM 		 * Property vector for BOOT_CONFIG_PG_OVR property group.
2289862SSherry.Moore@Sun.COM 		 */
2299862SSherry.Moore@Sun.COM 		scf_propvec_t ua_boot_config_ovr[] = {
2309862SSherry.Moore@Sun.COM 			{ FASTREBOOT_DEFAULT, NULL, SCF_TYPE_BOOLEAN, NULL,
2319862SSherry.Moore@Sun.COM 			    UA_FASTREBOOT_DEFAULT },
23210559SSherry.Moore@Sun.COM 			{ FASTREBOOT_ONPANIC, NULL, SCF_TYPE_BOOLEAN, NULL,
23310559SSherry.Moore@Sun.COM 			    UA_FASTREBOOT_ONPANIC },
2349862SSherry.Moore@Sun.COM 			{ NULL }
2359862SSherry.Moore@Sun.COM 		};
2369862SSherry.Moore@Sun.COM 		scf_propvec_t	*prop;
2379862SSherry.Moore@Sun.COM 
2389862SSherry.Moore@Sun.COM 		rc = scf_fmri_pg_get_or_add(FMRI_BOOT_CONFIG,
2399862SSherry.Moore@Sun.COM 		    BOOT_CONFIG_PG_OVR, SCF_GROUP_APPLICATION,
2409862SSherry.Moore@Sun.COM 		    SCF_PG_FLAG_NONPERSISTENT, set);
2419862SSherry.Moore@Sun.COM 
2429862SSherry.Moore@Sun.COM 		if (rc != SCF_SUCCESS) {
2439862SSherry.Moore@Sun.COM #if defined(FASTREBOOT_DEBUG)
2449862SSherry.Moore@Sun.COM 			if (set)
2459862SSherry.Moore@Sun.COM 				(void) uu_warn("Unable to add service %s "
2469862SSherry.Moore@Sun.COM 				    "property group '%s'\n",
2479862SSherry.Moore@Sun.COM 				    FMRI_BOOT_CONFIG, BOOT_CONFIG_PG_OVR);
2489862SSherry.Moore@Sun.COM #endif	/* FASTREBOOT_DEBUG */
2499862SSherry.Moore@Sun.COM 			return (rc);
2509862SSherry.Moore@Sun.COM 		}
2519862SSherry.Moore@Sun.COM 
2529862SSherry.Moore@Sun.COM 		for (prop = ua_boot_config_ovr; prop->pv_prop != NULL; prop++)
2539862SSherry.Moore@Sun.COM 			prop->pv_ptr = boot_config_ovr;
2549862SSherry.Moore@Sun.COM 		prop = NULL;
2559862SSherry.Moore@Sun.COM 
2569862SSherry.Moore@Sun.COM 		if (set)
2579862SSherry.Moore@Sun.COM 			rc = scf_write_propvec(FMRI_BOOT_CONFIG,
2589862SSherry.Moore@Sun.COM 			    BOOT_CONFIG_PG_OVR, ua_boot_config_ovr, &prop);
2599862SSherry.Moore@Sun.COM 		else
2609862SSherry.Moore@Sun.COM 			rc = scf_read_propvec(FMRI_BOOT_CONFIG,
2619862SSherry.Moore@Sun.COM 			    BOOT_CONFIG_PG_OVR, B_FALSE, ua_boot_config_ovr,
2629862SSherry.Moore@Sun.COM 			    &prop);
2639862SSherry.Moore@Sun.COM 
2649862SSherry.Moore@Sun.COM #if defined(FASTREBOOT_DEBUG)
2659862SSherry.Moore@Sun.COM 		if (rc != SCF_SUCCESS) {
2669862SSherry.Moore@Sun.COM 			if (prop != NULL) {
2679862SSherry.Moore@Sun.COM 				(void) uu_warn("Service %s property '%s/%s' "
2689862SSherry.Moore@Sun.COM 				    "not found.\n", FMRI_BOOT_CONFIG,
2699862SSherry.Moore@Sun.COM 				    BOOT_CONFIG_PG_OVR, prop->pv_prop);
2709862SSherry.Moore@Sun.COM 			} else {
2719862SSherry.Moore@Sun.COM 				(void) uu_warn("Unable to %s service %s "
2729862SSherry.Moore@Sun.COM 				    "property '%s': %s\n", set ? "set" : "get",
2739862SSherry.Moore@Sun.COM 				    FMRI_BOOT_CONFIG, BOOT_CONFIG_PG_OVR,
2749862SSherry.Moore@Sun.COM 				    scf_strerror(scf_error()));
2759862SSherry.Moore@Sun.COM 			}
2769862SSherry.Moore@Sun.COM 		}
2779862SSherry.Moore@Sun.COM #endif	/* FASTREBOOT_DEBUG */
27810559SSherry.Moore@Sun.COM 
27910559SSherry.Moore@Sun.COM 		if (set)
28010559SSherry.Moore@Sun.COM 			(void) smf_refresh_instance(FMRI_BOOT_CONFIG);
28110559SSherry.Moore@Sun.COM 
2829862SSherry.Moore@Sun.COM 		return (rc);
2839862SSherry.Moore@Sun.COM 
2849862SSherry.Moore@Sun.COM 	}
2859862SSherry.Moore@Sun.COM #endif	/* __x86 */
2869862SSherry.Moore@Sun.COM }
2879862SSherry.Moore@Sun.COM 
2889862SSherry.Moore@Sun.COM /*
2899862SSherry.Moore@Sun.COM  * Get values of properties in non-persistent "config_ovr" property group.
2909862SSherry.Moore@Sun.COM  */
29110559SSherry.Moore@Sun.COM void
scf_get_boot_config_ovr(uint8_t * boot_config_ovr)2929862SSherry.Moore@Sun.COM scf_get_boot_config_ovr(uint8_t *boot_config_ovr)
2939862SSherry.Moore@Sun.COM {
2949862SSherry.Moore@Sun.COM 	(void) scf_getset_boot_config_ovr(B_FALSE, boot_config_ovr);
2959862SSherry.Moore@Sun.COM }
2969862SSherry.Moore@Sun.COM 
2979862SSherry.Moore@Sun.COM /*
2989862SSherry.Moore@Sun.COM  * Set value of "config_ovr/fastreboot_default".
2999862SSherry.Moore@Sun.COM  */
3009862SSherry.Moore@Sun.COM int
scf_fastreboot_default_set_transient(boolean_t value)3019862SSherry.Moore@Sun.COM scf_fastreboot_default_set_transient(boolean_t value)
3029862SSherry.Moore@Sun.COM {
30310559SSherry.Moore@Sun.COM 	uint8_t	boot_config_ovr = 0;
30410559SSherry.Moore@Sun.COM 
30510559SSherry.Moore@Sun.COM 	if (value == B_TRUE)
30610559SSherry.Moore@Sun.COM 		boot_config_ovr = UA_FASTREBOOT_DEFAULT | UA_FASTREBOOT_ONPANIC;
3079862SSherry.Moore@Sun.COM 
3089862SSherry.Moore@Sun.COM 	return (scf_getset_boot_config_ovr(B_TRUE, &boot_config_ovr));
3099862SSherry.Moore@Sun.COM }
3109862SSherry.Moore@Sun.COM 
3119862SSherry.Moore@Sun.COM /*
3129160SSherry.Moore@Sun.COM  * Check whether Fast Reboot is the default operating mode.
3139160SSherry.Moore@Sun.COM  * Return 0 if
3149160SSherry.Moore@Sun.COM  *   1. the platform is xVM
3159160SSherry.Moore@Sun.COM  * or
3169160SSherry.Moore@Sun.COM  *   2. svc:/system/boot-config:default service doesn't exist,
3179160SSherry.Moore@Sun.COM  * or
3189862SSherry.Moore@Sun.COM  *   3. property "config/fastreboot_default" doesn't exist,
3199160SSherry.Moore@Sun.COM  * or
3209862SSherry.Moore@Sun.COM  *   4. value of property "config/fastreboot_default" is set to "false"
3219862SSherry.Moore@Sun.COM  *      and "config_ovr/fastreboot_default" is not set to "true",
3229160SSherry.Moore@Sun.COM  * or
3239160SSherry.Moore@Sun.COM  *   5. the platform has been blacklisted.
3249862SSherry.Moore@Sun.COM  * or
3259862SSherry.Moore@Sun.COM  *   6. value of property "config_ovr/fastreboot_default" is set to "false".
3269160SSherry.Moore@Sun.COM  * Return non-zero otherwise.
3279160SSherry.Moore@Sun.COM  */
3289160SSherry.Moore@Sun.COM int
scf_is_fastboot_default(void)3299160SSherry.Moore@Sun.COM scf_is_fastboot_default(void)
3309160SSherry.Moore@Sun.COM {
3319862SSherry.Moore@Sun.COM 	uint8_t	boot_config = 0, boot_config_ovr;
3329160SSherry.Moore@Sun.COM 	char procbuf[SYS_NMLN];
3339160SSherry.Moore@Sun.COM 
3349160SSherry.Moore@Sun.COM 	/*
3359160SSherry.Moore@Sun.COM 	 * If we are on xVM, do not fast reboot by default.
3369160SSherry.Moore@Sun.COM 	 */
3379160SSherry.Moore@Sun.COM 	if (sysinfo(SI_PLATFORM, procbuf, sizeof (procbuf)) == -1 ||
3389160SSherry.Moore@Sun.COM 	    strcmp(procbuf, "i86xpv") == 0)
3399160SSherry.Moore@Sun.COM 		return (0);
3409160SSherry.Moore@Sun.COM 
3419862SSherry.Moore@Sun.COM 	/*
3429862SSherry.Moore@Sun.COM 	 * Get property values from "config" property group
3439862SSherry.Moore@Sun.COM 	 */
3449160SSherry.Moore@Sun.COM 	scf_get_boot_config(&boot_config);
3459862SSherry.Moore@Sun.COM 
3469862SSherry.Moore@Sun.COM 	/*
3479862SSherry.Moore@Sun.COM 	 * Get property values from non-persistent "config_ovr" property group
3489862SSherry.Moore@Sun.COM 	 */
3499862SSherry.Moore@Sun.COM 	boot_config_ovr = boot_config;
3509862SSherry.Moore@Sun.COM 	scf_get_boot_config_ovr(&boot_config_ovr);
3519862SSherry.Moore@Sun.COM 
3529862SSherry.Moore@Sun.COM 	return (boot_config & boot_config_ovr & UA_FASTREBOOT_DEFAULT);
3539160SSherry.Moore@Sun.COM }
354