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 2000 Sun Microsystems, Inc. All rights reserved. 24*03831d35Sstevel * Use is subject to license terms. 25*03831d35Sstevel */ 26*03831d35Sstevel 27*03831d35Sstevel #ifndef _MBOXSC_IMPL_H 28*03831d35Sstevel #define _MBOXSC_IMPL_H 29*03831d35Sstevel 30*03831d35Sstevel #pragma ident "%Z%%M% %I% %E% SMI" 31*03831d35Sstevel 32*03831d35Sstevel /* 33*03831d35Sstevel * This file contains implementation details for the mboxsc API that need to 34*03831d35Sstevel * be shared amongst all implementations, but should be hidden from clients. 35*03831d35Sstevel */ 36*03831d35Sstevel 37*03831d35Sstevel #ifdef __cplusplus 38*03831d35Sstevel extern "C" { 39*03831d35Sstevel #endif 40*03831d35Sstevel 41*03831d35Sstevel /* 42*03831d35Sstevel * Version number of the current Mailbox Protocol implementation. This must 43*03831d35Sstevel * be updated whenever a new version of the Protocol is implemented. 44*03831d35Sstevel */ 45*03831d35Sstevel #define MBOXSC_PROTOCOL_VERSION 1 46*03831d35Sstevel 47*03831d35Sstevel /* 48*03831d35Sstevel * Mailbox message header and checksum. 49*03831d35Sstevel */ 50*03831d35Sstevel typedef struct { 51*03831d35Sstevel uint32_t msg_version; 52*03831d35Sstevel uint32_t msg_type; 53*03831d35Sstevel uint32_t msg_cmd; 54*03831d35Sstevel uint32_t msg_length; 55*03831d35Sstevel uint64_t msg_transid; 56*03831d35Sstevel } mboxsc_msghdr_t; 57*03831d35Sstevel 58*03831d35Sstevel typedef uint32_t mboxsc_chksum_t; 59*03831d35Sstevel 60*03831d35Sstevel /* 61*03831d35Sstevel * Constants for various aspects of the protocol. 62*03831d35Sstevel */ 63*03831d35Sstevel #define MBOXSC_MSGHDR_SIZE (sizeof (mboxsc_msghdr_t)) 64*03831d35Sstevel #define MBOXSC_CHKSUM_SIZE (sizeof (mboxsc_chksum_t)) 65*03831d35Sstevel #define MBOXSC_PROTOCOL_SIZE (MBOXSC_MSGHDR_SIZE + MBOXSC_CHKSUM_SIZE) 66*03831d35Sstevel #define MBOXSC_MSGHDR_OFFSET (0) 67*03831d35Sstevel #define MBOXSC_DATA_OFFSET MBOXSC_MSGHDR_SIZE 68*03831d35Sstevel 69*03831d35Sstevel /* 70*03831d35Sstevel * Timeouts used for various mboxsc operations. All timeouts are provided 71*03831d35Sstevel * in microseconds. 72*03831d35Sstevel * XXX - Aside from the conversion factors, these values are currently 73*03831d35Sstevel * somewhat arbitrary, and may need significant modification. 74*03831d35Sstevel */ 75*03831d35Sstevel #define MBOXSC_USECS_PER_SECOND (1000000L) 76*03831d35Sstevel #define MBOXSC_USECS_PER_MSEC (1000L) 77*03831d35Sstevel 78*03831d35Sstevel /* 79*03831d35Sstevel * The amount of time to sleep before retrying an IOSRAM operation that failed 80*03831d35Sstevel * because a tunnel switch was in progress. 81*03831d35Sstevel * Current value: 0.125 seconds 82*03831d35Sstevel */ 83*03831d35Sstevel #define MBOXSC_EAGAIN_POLL_USECS (MBOXSC_USECS_PER_SECOND / 8) 84*03831d35Sstevel 85*03831d35Sstevel /* 86*03831d35Sstevel * The interval at which the data_valid flag should be polled for a change in 87*03831d35Sstevel * status after sending a message. 88*03831d35Sstevel * Current value: 0.010 seconds 89*03831d35Sstevel */ 90*03831d35Sstevel #define MBOXSC_PUTMSG_POLL_USECS (MBOXSC_USECS_PER_SECOND / 100) 91*03831d35Sstevel 92*03831d35Sstevel /* 93*03831d35Sstevel * The polling rates for acquisition of the hardware lock used to synchronize 94*03831d35Sstevel * data_valid flag access. 95*03831d35Sstevel * Current values: 0.025 seconds 96*03831d35Sstevel */ 97*03831d35Sstevel #define MBOXSC_HWLOCK_POLL_USECS (MBOXSC_USECS_PER_SECOND / 40) 98*03831d35Sstevel 99*03831d35Sstevel /* 100*03831d35Sstevel * Minimum, default, and maximum times for mboxsc_putmsg to spend trying to send 101*03831d35Sstevel * a message before giving up. 102*03831d35Sstevel * Current value: 0.050, 10, and 1800 seconds, respectively 103*03831d35Sstevel * 1800 seconds (30 minutes) is a few minutes shy of the maximum 104*03831d35Sstevel * value of a clock_t in units of microseconds. 105*03831d35Sstevel */ 106*03831d35Sstevel #define MBOXSC_PUTMSG_MIN_TIMEOUT_USECS (MBOXSC_USECS_PER_SECOND / 20) 107*03831d35Sstevel #define MBOXSC_PUTMSG_DEF_TIMEOUT_USECS (MBOXSC_USECS_PER_SECOND * 10) 108*03831d35Sstevel #define MBOXSC_PUTMSG_MAX_TIMEOUT_USECS (MBOXSC_USECS_PER_SECOND * 60 * 30) 109*03831d35Sstevel 110*03831d35Sstevel #define MBOXSC_PUTMSG_MIN_TIMEOUT_MSECS \ 111*03831d35Sstevel (MBOXSC_PUTMSG_MIN_TIMEOUT_USECS / MBOXSC_USECS_PER_MSEC) 112*03831d35Sstevel #define MBOXSC_PUTMSG_DEF_TIMEOUT_MSECS \ 113*03831d35Sstevel (MBOXSC_PUTMSG_DEF_TIMEOUT_USECS / MBOXSC_USECS_PER_MSEC) 114*03831d35Sstevel #define MBOXSC_PUTMSG_MAX_TIMEOUT_MSECS \ 115*03831d35Sstevel (MBOXSC_PUTMSG_MAX_TIMEOUT_USECS / MBOXSC_USECS_PER_MSEC) 116*03831d35Sstevel 117*03831d35Sstevel /* 118*03831d35Sstevel * Minimum and maximum times for mboxsc_getmsg to spend trying to receive a 119*03831d35Sstevel * message before giving up. 120*03831d35Sstevel * Current value: 0 and 1800 seconds, respectively 121*03831d35Sstevel * 1800 seconds (30 minutes) is a few minutes shy of the maximum 122*03831d35Sstevel * value of a clock_t in units of microseconds. 123*03831d35Sstevel */ 124*03831d35Sstevel #define MBOXSC_GETMSG_MIN_TIMEOUT_USECS (MBOXSC_USECS_PER_SECOND * 0) 125*03831d35Sstevel #define MBOXSC_GETMSG_MAX_TIMEOUT_USECS (MBOXSC_USECS_PER_SECOND * 60 * 30) 126*03831d35Sstevel 127*03831d35Sstevel #define MBOXSC_GETMSG_MIN_TIMEOUT_MSECS \ 128*03831d35Sstevel (MBOXSC_GETMSG_MIN_TIMEOUT_USECS / MBOXSC_USECS_PER_MSEC) 129*03831d35Sstevel #define MBOXSC_GETMSG_MAX_TIMEOUT_MSECS \ 130*03831d35Sstevel (MBOXSC_GETMSG_MAX_TIMEOUT_USECS / MBOXSC_USECS_PER_MSEC) 131*03831d35Sstevel 132*03831d35Sstevel #ifdef __cplusplus 133*03831d35Sstevel } 134*03831d35Sstevel #endif 135*03831d35Sstevel 136*03831d35Sstevel #endif /* _MBOXSC_IMPL_H */ 137