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 #ifdef i386 32 /* 33 * On x86, we call topo interfaces to invoke the retire/unretire methods in the 34 * corresponding topo node. 35 * 36 */ 37 int 38 cma_fmri_page_service_state(fmd_hdl_t *hdl, nvlist_t *nvl) 39 { 40 return (fmd_nvl_fmri_service_state(hdl, nvl)); 41 } 42 43 int 44 cma_fmri_page_retire(fmd_hdl_t *hdl, nvlist_t *nvl) 45 { 46 return (fmd_nvl_fmri_retire(hdl, nvl)); 47 } 48 49 int 50 cma_fmri_page_unretire(fmd_hdl_t *hdl, nvlist_t *nvl) 51 { 52 return (fmd_nvl_fmri_unretire(hdl, nvl)); 53 } 54 #else 55 /* ARGSUSED */ 56 int 57 cma_fmri_page_service_state(fmd_hdl_t *hdl, nvlist_t *nvl) 58 { 59 fmd_agent_hdl_t *fa_hdl; 60 int rc = FMD_SERVICE_STATE_UNKNOWN; 61 62 if ((fa_hdl = fmd_agent_open(FMD_AGENT_VERSION)) != NULL) { 63 rc = fmd_agent_page_isretired(fa_hdl, nvl); 64 if (rc == FMD_AGENT_RETIRE_DONE) 65 rc = FMD_SERVICE_STATE_UNUSABLE; 66 else if (rc == FMD_AGENT_RETIRE_FAIL) 67 rc = FMD_SERVICE_STATE_OK; 68 else if (rc == FMD_AGENT_RETIRE_ASYNC) 69 rc = FMD_SERVICE_STATE_ISOLATE_PENDING; 70 fmd_agent_close(fa_hdl); 71 } 72 73 return (rc); 74 } 75 76 /* ARGSUSED */ 77 int 78 cma_fmri_page_retire(fmd_hdl_t *hdl, nvlist_t *nvl) 79 { 80 fmd_agent_hdl_t *fa_hdl; 81 int rc = FMD_AGENT_RETIRE_FAIL; 82 83 if ((fa_hdl = fmd_agent_open(FMD_AGENT_VERSION)) != NULL) { 84 rc = fmd_agent_page_retire(fa_hdl, nvl); 85 fmd_agent_close(fa_hdl); 86 } 87 88 return (rc); 89 } 90 91 /* ARGSUSED */ 92 int 93 cma_fmri_page_unretire(fmd_hdl_t *hdl, nvlist_t *nvl) 94 { 95 fmd_agent_hdl_t *fa_hdl; 96 int rc = FMD_AGENT_RETIRE_FAIL; 97 98 if ((fa_hdl = fmd_agent_open(FMD_AGENT_VERSION)) != NULL) { 99 rc = fmd_agent_page_unretire(fa_hdl, nvl); 100 fmd_agent_close(fa_hdl); 101 } 102 103 return (rc); 104 } 105 #endif 106