sun_pages.c revision 12126:60364f3f65c7
1183234Ssimon/* 2183234Ssimon * CDDL HEADER START 3238405Sjkim * 4183234Ssimon * The contents of this file are subject to the terms of the 5183234Ssimon * Common Development and Distribution License (the "License"). 6183234Ssimon * You may not use this file except in compliance with the License. 7183234Ssimon * 8183234Ssimon * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9183234Ssimon * or http://www.opensolaris.org/os/licensing. 10183234Ssimon * See the License for the specific language governing permissions 11183234Ssimon * and limitations under the License. 12183234Ssimon * 13183234Ssimon * When distributing Covered Code, include this CDDL HEADER in each 14183234Ssimon * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15183234Ssimon * If applicable, add the following below this CDDL HEADER, with the 16183234Ssimon * fields enclosed by brackets "[]" replaced with your own identifying 17183234Ssimon * information: Portions Copyright [yyyy] [name of copyright owner] 18183234Ssimon * 19183234Ssimon * CDDL HEADER END 20183234Ssimon */ 21183234Ssimon 22183234Ssimon/* 23183234Ssimon * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 24183234Ssimon */ 25183234Ssimon 26183234Ssimon#include <stddef.h> 27183234Ssimon#include <strings.h> 28183234Ssimon 29183234Ssimon#include <scsi/libses.h> 30183234Ssimon#include <scsi/libses_plugin.h> 31183234Ssimon#include <scsi/plugins/ses/vendor/sun.h> 32183234Ssimon#include <scsi/plugins/ses/vendor/sun_impl.h> 33183234Ssimon 34183234Ssimon/*ARGSUSED*/ 35183234Ssimonstatic void * 36183234Ssimonsun_fruid_index(ses_plugin_t *sp, ses_node_t *np, void *data, 37183234Ssimon size_t pagelen, size_t *len) 38183234Ssimon{ 39183234Ssimon uint64_t index; 40183234Ssimon nvlist_t *props = ses_node_props(np); 41183234Ssimon sun_fruid_page_impl_t *sfpip = data; 42183234Ssimon sun_fru_descr_impl_t *sfdip; 43183234Ssimon uint16_t *addr; 44183234Ssimon 45183234Ssimon if (ses_node_type(np) != SES_NODE_ELEMENT && 46183234Ssimon ses_node_type(np) != SES_NODE_ENCLOSURE) 47183234Ssimon return (NULL); 48183234Ssimon 49183234Ssimon if (nvlist_lookup_uint64(props, SES_PROP_ELEMENT_ONLY_INDEX, 50183234Ssimon &index) != 0) 51183234Ssimon return (NULL); 52183234Ssimon 53183234Ssimon addr = &sfpip->sfpi_descr_addrs[index]; 54183234Ssimon if (!SES_WITHIN_PAGE_STRUCT(addr, data, pagelen)) 55183234Ssimon return (NULL); 56183234Ssimon 57183234Ssimon sfdip = (sun_fru_descr_impl_t *)((uint8_t *)sfpip + SCSI_READ16(addr)); 58183234Ssimon if (!SES_WITHIN_PAGE_STRUCT(sfdip, data, pagelen)) 59183234Ssimon return (NULL); 60183234Ssimon 61183234Ssimon *len = MIN(((uint8_t *)sfpip - (uint8_t *)sfdip) + pagelen, 62183234Ssimon SCSI_READ16(&sfdip->sfdi_fru_data_length) + 63183234Ssimon offsetof(sun_fru_descr_impl_t, sfdi_fru_data)); 64183234Ssimon 65183234Ssimon return (sfdip); 66183234Ssimon} 67183234Ssimon 68183234Ssimonses_pagedesc_t sun_pages[] = { 69183234Ssimon{ 70183234Ssimon .spd_pagenum = SUN_DIAGPAGE_FRUID, 71183234Ssimon .spd_index = sun_fruid_index, 72183234Ssimon .spd_req = SES_REQ_OPTIONAL_STANDARD, 73183234Ssimon .spd_gcoff = offsetof(sun_fruid_page_impl_t, sfpi_generation_code) 74183234Ssimon}, 75183234Ssimon{ 76238405Sjkim .spd_pagenum = -1, 77183234Ssimon .spd_gcoff = -1 78183234Ssimon} 79183234Ssimon}; 80183234Ssimon