xref: /titanic_50/usr/src/cmd/fm/modules/common/cpumem-retire/cma_page_arch.c (revision 3f1e69bef33050bee99ea1e9992af13fc467281f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #include <fm/fmd_api.h>
28 #include <fm/fmd_agent.h>
29 #include <fm/fmd_fmri.h>
30 
31 /* ARGSUSED */
32 int
cma_fmri_page_service_state(fmd_hdl_t * hdl,nvlist_t * nvl)33 cma_fmri_page_service_state(fmd_hdl_t *hdl, nvlist_t *nvl)
34 {
35 	fmd_agent_hdl_t *fa_hdl;
36 	int rc;
37 
38 	if ((fa_hdl = fmd_agent_open(FMD_AGENT_VERSION)) != NULL) {
39 		rc = fmd_agent_page_isretired(fa_hdl, nvl);
40 		if (rc == FMD_AGENT_RETIRE_DONE)
41 			rc = FMD_SERVICE_STATE_UNUSABLE;
42 		else if (rc == FMD_AGENT_RETIRE_FAIL)
43 			rc = FMD_SERVICE_STATE_OK;
44 		else if (rc == FMD_AGENT_RETIRE_ASYNC)
45 			rc = FMD_SERVICE_STATE_ISOLATE_PENDING;
46 		fmd_agent_close(fa_hdl);
47 		return (rc);
48 	}
49 
50 	return (FMD_SERVICE_STATE_UNKNOWN);
51 }
52 
53 /* ARGSUSED */
54 int
cma_fmri_page_retire(fmd_hdl_t * hdl,nvlist_t * nvl)55 cma_fmri_page_retire(fmd_hdl_t *hdl, nvlist_t *nvl)
56 {
57 	fmd_agent_hdl_t *fa_hdl;
58 	int rc;
59 
60 	if ((fa_hdl = fmd_agent_open(FMD_AGENT_VERSION)) != NULL) {
61 		rc = fmd_agent_page_retire(fa_hdl, nvl);
62 		fmd_agent_close(fa_hdl);
63 		return (rc);
64 	}
65 
66 	return (FMD_AGENT_RETIRE_FAIL);
67 }
68 
69 /* ARGSUSED */
70 int
cma_fmri_page_unretire(fmd_hdl_t * hdl,nvlist_t * nvl)71 cma_fmri_page_unretire(fmd_hdl_t *hdl, nvlist_t *nvl)
72 {
73 	fmd_agent_hdl_t *fa_hdl;
74 	int rc;
75 
76 	if ((fa_hdl = fmd_agent_open(FMD_AGENT_VERSION)) != NULL) {
77 		rc = fmd_agent_page_unretire(fa_hdl, nvl);
78 		fmd_agent_close(fa_hdl);
79 		return (rc);
80 	}
81 
82 	return (FMD_AGENT_RETIRE_FAIL);
83 }
84