1*03831d35Sstevel /* 2*03831d35Sstevel * CDDL HEADER START 3*03831d35Sstevel * 4*03831d35Sstevel * The contents of this file are subject to the terms of the 5*03831d35Sstevel * Common Development and Distribution License (the "License"). 6*03831d35Sstevel * You may not use this file except in compliance with the License. 7*03831d35Sstevel * 8*03831d35Sstevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*03831d35Sstevel * or http://www.opensolaris.org/os/licensing. 10*03831d35Sstevel * See the License for the specific language governing permissions 11*03831d35Sstevel * and limitations under the License. 12*03831d35Sstevel * 13*03831d35Sstevel * When distributing Covered Code, include this CDDL HEADER in each 14*03831d35Sstevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*03831d35Sstevel * If applicable, add the following below this CDDL HEADER, with the 16*03831d35Sstevel * fields enclosed by brackets "[]" replaced with your own identifying 17*03831d35Sstevel * information: Portions Copyright [yyyy] [name of copyright owner] 18*03831d35Sstevel * 19*03831d35Sstevel * CDDL HEADER END 20*03831d35Sstevel */ 21*03831d35Sstevel 22*03831d35Sstevel /* 23*03831d35Sstevel * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*03831d35Sstevel * Use is subject to license terms. 25*03831d35Sstevel */ 26*03831d35Sstevel 27*03831d35Sstevel #ifndef _SGFRU_MBOX_H 28*03831d35Sstevel #define _SGFRU_MBOX_H 29*03831d35Sstevel 30*03831d35Sstevel #pragma ident "%Z%%M% %I% %E% SMI" 31*03831d35Sstevel 32*03831d35Sstevel #ifdef __cplusplus 33*03831d35Sstevel extern "C" { 34*03831d35Sstevel #endif 35*03831d35Sstevel 36*03831d35Sstevel #include <sys/sgfru_priv.h> 37*03831d35Sstevel #include <sys/conf.h> 38*03831d35Sstevel #include <sys/ddi_impldefs.h> 39*03831d35Sstevel 40*03831d35Sstevel /* 41*03831d35Sstevel * Max time sgfru waits for mailbox to respond before 42*03831d35Sstevel * it decides to timeout. (measured in seconds) 43*03831d35Sstevel */ 44*03831d35Sstevel #define SGFRU_DEFAULT_MAX_MBOX_WAIT_TIME 86400 45*03831d35Sstevel 46*03831d35Sstevel /* 47*03831d35Sstevel * FRU Mailbox Definitions 48*03831d35Sstevel * 49*03831d35Sstevel * Request (from Solaris to SC): 50*03831d35Sstevel * msg_len = CONTAINER_HDL_SIZE 51*03831d35Sstevel * msg_buf = pointer to unpadded container_hdl_t 52*03831d35Sstevel * Response (from SC to Solaris): 53*03831d35Sstevel * msg_len = FRU_CNT_SIZE 54*03831d35Sstevel * msg_buf = pointer to unpadded fru_cnt_t 55*03831d35Sstevel * msg_status = return value, see below. 56*03831d35Sstevel * Error Notes: 57*03831d35Sstevel */ 58*03831d35Sstevel #define SGFRU_MBOX_GETNUMSECTIONS 0x7001 59*03831d35Sstevel /* 60*03831d35Sstevel * Request (from Solaris to SC): 61*03831d35Sstevel * msg_len = FRU_INFO_SIZE 62*03831d35Sstevel * msg_buf = pointer to unpadded fru_info_t containing: 63*03831d35Sstevel * parent container_hdl_t and max fru_cnt_t (in #sections) 64*03831d35Sstevel * Response (from SC to Solaris): 65*03831d35Sstevel * msg_len = FRU_INFO_SIZE + (SECTION_SIZE * max fru_cnt_t) 66*03831d35Sstevel * msg_buf = caddr_t of msg_len, contains: 67*03831d35Sstevel * unpadded container_hdl_t and actual fru_cnt_t 68*03831d35Sstevel * unpadded section_t array 69*03831d35Sstevel * msg_status = return value, see below. 70*03831d35Sstevel * Error Notes: 71*03831d35Sstevel * Please return SG_MBOX_STATUS_NO_MEMORY if the buffer is not big enough. 72*03831d35Sstevel */ 73*03831d35Sstevel #define SGFRU_MBOX_GETSECTIONS 0x7002 74*03831d35Sstevel /* 75*03831d35Sstevel * Request (from Solaris to SC): 76*03831d35Sstevel * msg_len = SECTION_HDL_SIZE 77*03831d35Sstevel * msg_buf = pointer to unpadded section_hdl_t 78*03831d35Sstevel * Response (from SC to Solaris): 79*03831d35Sstevel * msg_len = FRU_CNT_SIZE 80*03831d35Sstevel * msg_buf = pointer to unpadded fru_cnt_t 81*03831d35Sstevel * msg_status = return value, see below. 82*03831d35Sstevel * Error Notes: 83*03831d35Sstevel */ 84*03831d35Sstevel #define SGFRU_MBOX_GETNUMSEGMENTS 0x7003 85*03831d35Sstevel /* 86*03831d35Sstevel * FRU Mailbox definitions 87*03831d35Sstevel * 88*03831d35Sstevel * Request (from Solaris to SC): 89*03831d35Sstevel * msg_len = FRU_INFO_SIZE 90*03831d35Sstevel * msg_buf = pointer to unpadded fru_info_t containing: 91*03831d35Sstevel * parent section_hdl_t and max fru_cnt_t (in #segments) 92*03831d35Sstevel * Response (from SC to Solaris): 93*03831d35Sstevel * msg_len = FRU_INFO_SIZE + (SEGMENT_SIZE * max fru_cnt_t) 94*03831d35Sstevel * msg_buf = caddr_t of msg_len, contains: 95*03831d35Sstevel * unpadded parent section_hdl_t and actual fru_cnt_t 96*03831d35Sstevel * unpadded segment_t array 97*03831d35Sstevel * msg_status = return value, see below. 98*03831d35Sstevel * Error Notes: 99*03831d35Sstevel * Please return SG_MBOX_STATUS_NO_MEMORY if the buffer is not big enough. 100*03831d35Sstevel */ 101*03831d35Sstevel #define SGFRU_MBOX_GETSEGMENTS 0x7004 102*03831d35Sstevel /* 103*03831d35Sstevel * Request (from Solaris to SC): 104*03831d35Sstevel * msg_len = SECTION_HDL_SIZE + SEGMENT_SIZE 105*03831d35Sstevel * msg_buf = caddr_t of msg_len, contains: 106*03831d35Sstevel * unpadded parent section_hdl_t 107*03831d35Sstevel * unpadded segment_t 108*03831d35Sstevel * Response (from SC to Solaris): 109*03831d35Sstevel * msg_len = SEGMENT_HDL_SIZE 110*03831d35Sstevel * msg_buf = pointer to: 111*03831d35Sstevel * segment_hdl_t of newly created segment 112*03831d35Sstevel * updated parent section_hdl_t 113*03831d35Sstevel * msg_status = return value, see below. 114*03831d35Sstevel * Error Notes: 115*03831d35Sstevel * Please return SG_MBOX_STATUS_STALE_OBJECT if the section_hdl_t is stale. 116*03831d35Sstevel * Please return SG_MBOX_STATUS_NO_SEPROM_SPACE if the seprom is out of space 117*03831d35Sstevel */ 118*03831d35Sstevel #define SGFRU_MBOX_ADDSEGMENT 0x7005 119*03831d35Sstevel /* 120*03831d35Sstevel * Request (from Solaris to SC): 121*03831d35Sstevel * msg_len = SEGMENT_HDL_SIZE 122*03831d35Sstevel * msg_buf = pointer to segment_hdl_t of segment to be deleted 123*03831d35Sstevel * Response (from SC to Solaris): 124*03831d35Sstevel * msg_len = SECTION_HDL_SIZE 125*03831d35Sstevel * msg_buf = pointer to updated section_hdl_t of deleted segment 126*03831d35Sstevel * msg_status = return value, see below 127*03831d35Sstevel * Error Notes: 128*03831d35Sstevel */ 129*03831d35Sstevel #define SGFRU_MBOX_DELETESEGMENT 0x7006 130*03831d35Sstevel /* 131*03831d35Sstevel * Request (from Solaris to SC): 132*03831d35Sstevel * msg_len = FRU_INFO_SIZE 133*03831d35Sstevel * msg_buf = caddr_t of msg_len, contains: 134*03831d35Sstevel * unpadded fru_info_t: segment_hdl_t and max count in bytes 135*03831d35Sstevel * Response (from SC to Solaris): 136*03831d35Sstevel * msg_len = FRU_INFO_SIZE 137*03831d35Sstevel * msg_buf = caddr_t of msg_len, contains: 138*03831d35Sstevel * unpadded fru_info_t: segment_hdl_t and actual count in bytes 139*03831d35Sstevel * unpadded data of actual fru_cnt_t bytes 140*03831d35Sstevel * msg_status = return value, see below. 141*03831d35Sstevel * Error Notes: 142*03831d35Sstevel * Please return SG_MBOX_STATUS_NO_MEMORY if the buffer is not big enough. 143*03831d35Sstevel */ 144*03831d35Sstevel #define SGFRU_MBOX_READRAWSEGMENT 0x7007 145*03831d35Sstevel /* 146*03831d35Sstevel * Request (from Solaris to SC): 147*03831d35Sstevel * msg_len = FRU_INFO_SIZE + fru_cnt_t bytes 148*03831d35Sstevel * msg_buf = caddr_t of msg_len, contains: 149*03831d35Sstevel * unpadded fru_info_t: segment_hdl_t and count in bytes 150*03831d35Sstevel * unpadded data of fru_cnt_t bytes 151*03831d35Sstevel * Response (from SC to Solaris): 152*03831d35Sstevel * msg_len = FRU_INFO_SIZE 153*03831d35Sstevel * msg_buf = caddr_t of msg_len, contains: 154*03831d35Sstevel * unpadded fru_info_t: segment_hdl_t and count in bytes 155*03831d35Sstevel * msg_status = return value, see below. 156*03831d35Sstevel * Error Notes: 157*03831d35Sstevel * Please return SG_MBOX_STATUS_ILLEGAL_PARAMETER if it's 158*03831d35Sstevel * not an opaque segment. 159*03831d35Sstevel */ 160*03831d35Sstevel #define SGFRU_MBOX_WRITERAWSEGMENT 0x7008 161*03831d35Sstevel /* 162*03831d35Sstevel * Request (from Solaris to SC): 163*03831d35Sstevel * msg_len = SEGMENT_HDL_SIZE 164*03831d35Sstevel * msg_buf = pointer to unpadded segment_hdl_t 165*03831d35Sstevel * Response (from SC to Solaris): 166*03831d35Sstevel * msg_len = FRU_CNT_SIZE 167*03831d35Sstevel * msg_buf = pointer to unpadded fru_cnt_t 168*03831d35Sstevel * msg_status = return value, see below. 169*03831d35Sstevel * Error Notes: 170*03831d35Sstevel */ 171*03831d35Sstevel #define SGFRU_MBOX_GETNUMPACKETS 0x7009 172*03831d35Sstevel /* 173*03831d35Sstevel * Request (from Solaris to SC): 174*03831d35Sstevel * msg_len = FRU_INFO_SIZE 175*03831d35Sstevel * msg_buf = pointer to unpadded fru_info_t, containing: 176*03831d35Sstevel * unpadded segment_hdl_t plus max fru_cnt_t in bytes 177*03831d35Sstevel * Response (from SC to Solaris): 178*03831d35Sstevel * msg_len = FRU_INFO_SIZE + (PACKET_SIZE * max fru_cnt_t) 179*03831d35Sstevel * msg_buf = caddr_t of msg_len, contains: 180*03831d35Sstevel * unpadded parent segment_hdl_t and actual fru_cnt_t 181*03831d35Sstevel * unpadded packet_t array 182*03831d35Sstevel * msg_status = return value, see below. 183*03831d35Sstevel * Error Notes: 184*03831d35Sstevel * Please return SG_MBOX_STATUS_NO_MEMORY if the buffer is not big enough. 185*03831d35Sstevel */ 186*03831d35Sstevel #define SGFRU_MBOX_GETPACKETS 0x700a 187*03831d35Sstevel /* 188*03831d35Sstevel * Request (from Solaris to SC): 189*03831d35Sstevel * msg_len = FRU_INFO_SIZE + PACKET_SIZE + fru_cnt_t size 190*03831d35Sstevel * msg_buf = caddr_t of msg_len, contains: 191*03831d35Sstevel * unpadded fru_info_t with parent segment_hdl_t and fru_cnt_t 192*03831d35Sstevel * unpadded packet_t 193*03831d35Sstevel * unpadded data of size fru_cnt_t (in bytes) 194*03831d35Sstevel * Response (from SC to Solaris): 195*03831d35Sstevel * msg_len = SEGMENT_HDL_SIZE + PACKET_HDL_SIZE 196*03831d35Sstevel * msg_buf = pointer to: 197*03831d35Sstevel * packet_hdl_t of newly created packet 198*03831d35Sstevel * updated parent segment_hdl_t 199*03831d35Sstevel * msg_status = return value, see below. 200*03831d35Sstevel * Error Notes: 201*03831d35Sstevel * Please return SG_MBOX_STATUS_NO_SEPROM_SPACE if the seprom is out of space 202*03831d35Sstevel */ 203*03831d35Sstevel #define SGFRU_MBOX_APPENDPACKET 0x700b 204*03831d35Sstevel /* 205*03831d35Sstevel * Request (from Solaris to SC): 206*03831d35Sstevel * msg_len = PACKET_HDL_SIZE 207*03831d35Sstevel * msg_buf = pointer to packet_hdl_t of packet to be deleted 208*03831d35Sstevel * Response (from SC to Solaris): 209*03831d35Sstevel * msg_len = SEGMENT_HDL_SIZE 210*03831d35Sstevel * msg_buf = pointer to updated segment_hdl_t of deleted packet 211*03831d35Sstevel * msg_status = return value, see below 212*03831d35Sstevel * Error Notes: 213*03831d35Sstevel */ 214*03831d35Sstevel #define SGFRU_MBOX_DELETEPACKET 0x700c 215*03831d35Sstevel /* 216*03831d35Sstevel * Request (from Solaris to SC): 217*03831d35Sstevel * msg_len = FRU_INFO_SIZE 218*03831d35Sstevel * msg_buf = caddr_t of msg_len, contains: 219*03831d35Sstevel * unpadded fru_info_t with packet_hdl_t and max fru_cnt_t 220*03831d35Sstevel * Response (from SC to Solaris): 221*03831d35Sstevel * msg_len = FRU_INFO_SIZE + max fru_cnt_t 222*03831d35Sstevel * msg_buf = caddr_t of msg_len, contains: 223*03831d35Sstevel * unpadded fru_info_t with packet_hdl_t and actual fru_cnt_t 224*03831d35Sstevel * unpadded data of size fru_cnt_t (in bytes) 225*03831d35Sstevel * msg_status = return value, see below. 226*03831d35Sstevel * Error Notes: 227*03831d35Sstevel * Please return SG_MBOX_STATUS_NO_MEMORY if the buffer is not big enough. 228*03831d35Sstevel */ 229*03831d35Sstevel #define SGFRU_MBOX_GETPAYLOAD 0x700d 230*03831d35Sstevel /* 231*03831d35Sstevel * Request (from Solaris to SC): 232*03831d35Sstevel * msg_len = FRU_INFO_SIZE + fru_cnt_t size 233*03831d35Sstevel * msg_buf = caddr_t of msg_len, contains: 234*03831d35Sstevel * unpadded fru_info_t with packet_hdl_t and actual count 235*03831d35Sstevel * unpadded payload data buf of fru_cnt_t size (in bytes) 236*03831d35Sstevel * Response (from SC to Solaris): 237*03831d35Sstevel * msg_len = FRU_INFO_SIZE 238*03831d35Sstevel * msg_buf = caddr_t of msg_len, contains: 239*03831d35Sstevel * unpadded fru_hdl_t with updated handle 240*03831d35Sstevel * unpadded data of size fru_cnt_t (in bytes) 241*03831d35Sstevel * msg_status = return value, see below. 242*03831d35Sstevel * Error Notes: 243*03831d35Sstevel * Please return SG_MBOX_STATUS_NO_SEPROM_SPACE if the seprom is out of space 244*03831d35Sstevel */ 245*03831d35Sstevel #define SGFRU_MBOX_UPDATEPAYLOAD 0x700e 246*03831d35Sstevel /* 247*03831d35Sstevel * FRU Mailbox Definitions 248*03831d35Sstevel * 249*03831d35Sstevel * Request (from Solaris to SC): 250*03831d35Sstevel * msg_len = FRU_INFO_SIZE 251*03831d35Sstevel * msg_buf = pointer to unpadded fru_info_t containing: 252*03831d35Sstevel * parent fru_hdl_t and max fru_cnt_t (in node_t's) 253*03831d35Sstevel * Response (from SC to Solaris): 254*03831d35Sstevel * msg_len = NODE_SIZE * max fru_cnt_t (in node_t's) 255*03831d35Sstevel * msg_buf = caddr_t of msg_len, contains: 256*03831d35Sstevel * unpadded fru_hdl_t and actual fru_cnt_t 257*03831d35Sstevel * unpadded node_t array 258*03831d35Sstevel * msg_status = return value, see below. 259*03831d35Sstevel * Error Notes: 260*03831d35Sstevel */ 261*03831d35Sstevel #define SGFRU_MBOX_GETCHILDLIST 0x700f 262*03831d35Sstevel /* 263*03831d35Sstevel * FRU Mailbox Definitions 264*03831d35Sstevel * 265*03831d35Sstevel * Request (from Solaris to SC): 266*03831d35Sstevel * msg_len = FRU_INFO_SIZE 267*03831d35Sstevel * msg_buf = pointer to unpadded fru_info_t containing: 268*03831d35Sstevel * parent fru_hdl_t and max fru_cnt_t (in fru_hdl_t's) 269*03831d35Sstevel * Response (from SC to Solaris): 270*03831d35Sstevel * msg_len = FRU_HDL_SIZE * max fru_cnt_t (in fru_hdl_t's) 271*03831d35Sstevel * msg_buf = caddr_t of msg_len, contains: 272*03831d35Sstevel * unpadded fru_hdl_t and actual fru_cnt_t 273*03831d35Sstevel * unpadded fru_hdl_t array 274*03831d35Sstevel * msg_status = return value, see below. 275*03831d35Sstevel * Error Notes: 276*03831d35Sstevel */ 277*03831d35Sstevel #define SGFRU_MBOX_GETCHILDHANDLES 0x7010 278*03831d35Sstevel /* 279*03831d35Sstevel * Request (from Solaris to SC): 280*03831d35Sstevel * msg_len = FRU_INFO_SIZE 281*03831d35Sstevel * msg_buf = pointer to unpadded fru_hdl_t 282*03831d35Sstevel * Response (from SC to Solaris): 283*03831d35Sstevel * msg_len = NODE_SIZE 284*03831d35Sstevel * msg_buf = caddr_t of msg_len, contains: 285*03831d35Sstevel * unpadded node_t 286*03831d35Sstevel * msg_status = return value, see below. 287*03831d35Sstevel * Error Notes: 288*03831d35Sstevel */ 289*03831d35Sstevel #define SGFRU_MBOX_GETNODEINFO 0x7020 290*03831d35Sstevel 291*03831d35Sstevel 292*03831d35Sstevel /* 293*03831d35Sstevel * The defines below are used for translating padded (C) to non-padded (Java), 294*03831d35Sstevel * and must directly correspond to the structures defined in fru_data_access.h 295*03831d35Sstevel * and sgfru.h. 296*03831d35Sstevel */ 297*03831d35Sstevel #define FRU_HDL_SIZE sizeof (fru_hdl_t) 298*03831d35Sstevel #define CONTAINER_HDL_SIZE FRU_HDL_SIZE 299*03831d35Sstevel #define SECTION_HDL_SIZE FRU_HDL_SIZE 300*03831d35Sstevel #define SEGMENT_HDL_SIZE FRU_HDL_SIZE 301*03831d35Sstevel #define PACKET_HDL_SIZE FRU_HDL_SIZE 302*03831d35Sstevel #define FRU_CNT_SIZE sizeof (fru_cnt_t) 303*03831d35Sstevel #define NAME_SIZE sizeof (char[SEG_NAME_LEN]) 304*03831d35Sstevel #define OFFSET_SIZE sizeof (uint32_t) 305*03831d35Sstevel #define LENGTH_SIZE sizeof (uint32_t) 306*03831d35Sstevel #define PROTECTED_SIZE sizeof (uint32_t) 307*03831d35Sstevel #define VERSION_SIZE sizeof (uint32_t) 308*03831d35Sstevel #define DESCRIPTOR_SIZE sizeof (uint32_t) 309*03831d35Sstevel #define TAG_SIZE sizeof (tag_t) 310*03831d35Sstevel #define NODENAME_SIZE sizeof (char[MAX_NODE_NAME]) 311*03831d35Sstevel #define HASCHILDREN_SIZE sizeof (uint16_t) 312*03831d35Sstevel #define CLASS_SIZE sizeof (uint16_t) 313*03831d35Sstevel #define CLASS_INFO_SIZE sizeof (union class_info) 314*03831d35Sstevel #define SLOT_SIZE sizeof (uint16_t) 315*03831d35Sstevel #define LABEL_SIZE sizeof (char[MAX_NODE_NAME]) 316*03831d35Sstevel 317*03831d35Sstevel #define FRU_INFO_SIZE (FRU_HDL_SIZE + FRU_CNT_SIZE) 318*03831d35Sstevel #define SECTION_SIZE (SECTION_HDL_SIZE + OFFSET_SIZE +\ 319*03831d35Sstevel LENGTH_SIZE + PROTECTED_SIZE + VERSION_SIZE) 320*03831d35Sstevel #define SEGMENT_SIZE (SEGMENT_HDL_SIZE + NAME_SIZE +\ 321*03831d35Sstevel DESCRIPTOR_SIZE + OFFSET_SIZE + LENGTH_SIZE) 322*03831d35Sstevel #define PACKET_SIZE (PACKET_HDL_SIZE + TAG_SIZE) 323*03831d35Sstevel #define NODE_SIZE (FRU_HDL_SIZE + NODENAME_SIZE +\ 324*03831d35Sstevel HASCHILDREN_SIZE + CLASS_SIZE +\ 325*03831d35Sstevel CLASS_INFO_SIZE) 326*03831d35Sstevel 327*03831d35Sstevel static int sgfru_mbox(const int cmd, char *datap, const size_t size, 328*03831d35Sstevel fru_info_t *fru); 329*03831d35Sstevel 330*03831d35Sstevel static caddr_t sgfru_fru_pad(const caddr_t datap, fru_info_t *fru); 331*03831d35Sstevel static int sgfru_node_pad(const caddr_t datap, const int max_cnt, 332*03831d35Sstevel fru_info_t *fru, node_t *nodep); 333*03831d35Sstevel static int sgfru_section_pad(const caddr_t datap, const int max_cnt, 334*03831d35Sstevel fru_info_t *fru, section_t *sectp); 335*03831d35Sstevel static int sgfru_segment_pad(const caddr_t datap, const int max_cnt, 336*03831d35Sstevel fru_info_t *fru, segment_t *segp); 337*03831d35Sstevel static int sgfru_packet_pad(const caddr_t datap, const int max_cnt, 338*03831d35Sstevel fru_info_t *fru, packet_t *packp); 339*03831d35Sstevel 340*03831d35Sstevel static caddr_t sgfru_fru_unpad(const fru_info_t *fru, caddr_t datap); 341*03831d35Sstevel static void sgfru_segment_unpad(const fru_info_t *fru, const segment_t *segp, 342*03831d35Sstevel caddr_t datap); 343*03831d35Sstevel static caddr_t sgfru_packet_unpad(const fru_info_t *fru, const packet_t *packp, 344*03831d35Sstevel caddr_t datap); 345*03831d35Sstevel 346*03831d35Sstevel #ifdef __cplusplus 347*03831d35Sstevel } 348*03831d35Sstevel #endif 349*03831d35Sstevel 350*03831d35Sstevel #endif /* _SGFRU_MBOX_H */ 351