15f149bcaScy /*
25f149bcaScy  * CDDL HEADER START
35f149bcaScy  *
45f149bcaScy  * The contents of this file are subject to the terms of the
55f149bcaScy  * Common Development and Distribution License (the "License").
65f149bcaScy  * You may not use this file except in compliance with the License.
75f149bcaScy  *
85f149bcaScy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95f149bcaScy  * or http://www.opensolaris.org/os/licensing.
105f149bcaScy  * See the License for the specific language governing permissions
115f149bcaScy  * and limitations under the License.
125f149bcaScy  *
135f149bcaScy  * When distributing Covered Code, include this CDDL HEADER in each
145f149bcaScy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155f149bcaScy  * If applicable, add the following below this CDDL HEADER, with the
165f149bcaScy  * fields enclosed by brackets "[]" replaced with your own identifying
175f149bcaScy  * information: Portions Copyright [yyyy] [name of copyright owner]
185f149bcaScy  *
195f149bcaScy  * CDDL HEADER END
205f149bcaScy  */
215f149bcaScy 
225f149bcaScy /*
235f149bcaScy  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
245f149bcaScy  * Use is subject to license terms.
255f149bcaScy  */
265f149bcaScy 
27e4b86885SCheng Sean Ye #include <fm/fmd_api.h>
28e4b86885SCheng Sean Ye #include <fm/fmd_agent.h>
29e4b86885SCheng Sean Ye #include <fm/fmd_fmri.h>
305f149bcaScy 
31e4b86885SCheng Sean Ye /* ARGSUSED */
32e4b86885SCheng Sean Ye int
cma_fmri_page_service_state(fmd_hdl_t * hdl,nvlist_t * nvl)33e4b86885SCheng Sean Ye cma_fmri_page_service_state(fmd_hdl_t *hdl, nvlist_t *nvl)
34e4b86885SCheng Sean Ye {
35e4b86885SCheng Sean Ye 	fmd_agent_hdl_t *fa_hdl;
36*3f1e69beSCheng Sean Ye 	int rc;
375f149bcaScy 
38e4b86885SCheng Sean Ye 	if ((fa_hdl = fmd_agent_open(FMD_AGENT_VERSION)) != NULL) {
39e4b86885SCheng Sean Ye 		rc = fmd_agent_page_isretired(fa_hdl, nvl);
40e4b86885SCheng Sean Ye 		if (rc == FMD_AGENT_RETIRE_DONE)
41e4b86885SCheng Sean Ye 			rc = FMD_SERVICE_STATE_UNUSABLE;
42e4b86885SCheng Sean Ye 		else if (rc == FMD_AGENT_RETIRE_FAIL)
43e4b86885SCheng Sean Ye 			rc = FMD_SERVICE_STATE_OK;
44e4b86885SCheng Sean Ye 		else if (rc == FMD_AGENT_RETIRE_ASYNC)
45e4b86885SCheng Sean Ye 			rc = FMD_SERVICE_STATE_ISOLATE_PENDING;
46e4b86885SCheng Sean Ye 		fmd_agent_close(fa_hdl);
47*3f1e69beSCheng Sean Ye 		return (rc);
485f149bcaScy 	}
495f149bcaScy 
50*3f1e69beSCheng Sean Ye 	return (FMD_SERVICE_STATE_UNKNOWN);
51e4b86885SCheng Sean Ye }
525f149bcaScy 
53e4b86885SCheng Sean Ye /* ARGSUSED */
54e4b86885SCheng Sean Ye int
cma_fmri_page_retire(fmd_hdl_t * hdl,nvlist_t * nvl)55e4b86885SCheng Sean Ye cma_fmri_page_retire(fmd_hdl_t *hdl, nvlist_t *nvl)
56e4b86885SCheng Sean Ye {
57e4b86885SCheng Sean Ye 	fmd_agent_hdl_t *fa_hdl;
58*3f1e69beSCheng Sean Ye 	int rc;
595f149bcaScy 
60e4b86885SCheng Sean Ye 	if ((fa_hdl = fmd_agent_open(FMD_AGENT_VERSION)) != NULL) {
61e4b86885SCheng Sean Ye 		rc = fmd_agent_page_retire(fa_hdl, nvl);
62e4b86885SCheng Sean Ye 		fmd_agent_close(fa_hdl);
63*3f1e69beSCheng Sean Ye 		return (rc);
64e4b86885SCheng Sean Ye 	}
655f149bcaScy 
66*3f1e69beSCheng Sean Ye 	return (FMD_AGENT_RETIRE_FAIL);
67e4b86885SCheng Sean Ye }
685f149bcaScy 
69e4b86885SCheng Sean Ye /* ARGSUSED */
70e4b86885SCheng Sean Ye int
cma_fmri_page_unretire(fmd_hdl_t * hdl,nvlist_t * nvl)71e4b86885SCheng Sean Ye cma_fmri_page_unretire(fmd_hdl_t *hdl, nvlist_t *nvl)
72e4b86885SCheng Sean Ye {
73e4b86885SCheng Sean Ye 	fmd_agent_hdl_t *fa_hdl;
74*3f1e69beSCheng Sean Ye 	int rc;
755f149bcaScy 
76e4b86885SCheng Sean Ye 	if ((fa_hdl = fmd_agent_open(FMD_AGENT_VERSION)) != NULL) {
77e4b86885SCheng Sean Ye 		rc = fmd_agent_page_unretire(fa_hdl, nvl);
78e4b86885SCheng Sean Ye 		fmd_agent_close(fa_hdl);
79*3f1e69beSCheng Sean Ye 		return (rc);
805f149bcaScy 	}
815f149bcaScy 
82*3f1e69beSCheng Sean Ye 	return (FMD_AGENT_RETIRE_FAIL);
835f149bcaScy }
84