10Sstevel@tonic-gate /* 2*1121Sjroberts * CDDL HEADER START 3*1121Sjroberts * 4*1121Sjroberts * The contents of this file are subject to the terms of the 5*1121Sjroberts * Common Development and Distribution License (the "License"). 6*1121Sjroberts * You may not use this file except in compliance with the License. 7*1121Sjroberts * 8*1121Sjroberts * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*1121Sjroberts * or http://www.opensolaris.org/os/licensing. 10*1121Sjroberts * See the License for the specific language governing permissions 11*1121Sjroberts * and limitations under the License. 12*1121Sjroberts * 13*1121Sjroberts * When distributing Covered Code, include this CDDL HEADER in each 14*1121Sjroberts * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*1121Sjroberts * If applicable, add the following below this CDDL HEADER, with the 16*1121Sjroberts * fields enclosed by brackets "[]" replaced with your own identifying 17*1121Sjroberts * information: Portions Copyright [yyyy] [name of copyright owner] 18*1121Sjroberts * 19*1121Sjroberts * CDDL HEADER END 20*1121Sjroberts */ 21*1121Sjroberts 22*1121Sjroberts /* 23*1121Sjroberts * Copyright 2002 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _SYS_RMC_COMM_LPROTO_H 280Sstevel@tonic-gate #define _SYS_RMC_COMM_LPROTO_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifdef __cplusplus 330Sstevel@tonic-gate extern "C" { 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate 360Sstevel@tonic-gate #define SYNC_CHAR 0x80 370Sstevel@tonic-gate #define ESC_CHAR 0x81 380Sstevel@tonic-gate 390Sstevel@tonic-gate /* Maximum message length */ 400Sstevel@tonic-gate 410Sstevel@tonic-gate #define DP_MAX_MSGLEN 1024 420Sstevel@tonic-gate 430Sstevel@tonic-gate /* 440Sstevel@tonic-gate * Tunables. 450Sstevel@tonic-gate */ 460Sstevel@tonic-gate 470Sstevel@tonic-gate /* Number of times a transmitted message will be retried. */ 480Sstevel@tonic-gate #define TX_RETRIES 10 490Sstevel@tonic-gate 500Sstevel@tonic-gate /* Amount of time between transmit retries in ms, currently 500ms. */ 510Sstevel@tonic-gate #define TX_RETRY_TIME 500L 520Sstevel@tonic-gate 530Sstevel@tonic-gate /* minimum waiting time for a reply (milliseconds) */ 540Sstevel@tonic-gate #define DP_MIN_TIMEOUT 200L 550Sstevel@tonic-gate 560Sstevel@tonic-gate /* 570Sstevel@tonic-gate * timeout (in ms) for (re)trying to establish the protocol data link 580Sstevel@tonic-gate */ 590Sstevel@tonic-gate #define DELAY_DP_SETUP 10 600Sstevel@tonic-gate #define RETRY_DP_SETUP 5000 610Sstevel@tonic-gate 620Sstevel@tonic-gate /* 630Sstevel@tonic-gate * Data protocol message structure. Note that this is the in-memory 640Sstevel@tonic-gate * version; when a data protocol message is transmitted it goes 650Sstevel@tonic-gate * through a translation to assist the receiving side in determining 660Sstevel@tonic-gate * message boundaries robustly. 670Sstevel@tonic-gate */ 680Sstevel@tonic-gate typedef struct dp_header { 690Sstevel@tonic-gate 700Sstevel@tonic-gate uint8_t pad; /* This pad byte is never transmitted nor */ 710Sstevel@tonic-gate /* received, it is solely to make the */ 720Sstevel@tonic-gate /* structure elements line up in memory. */ 730Sstevel@tonic-gate uint8_t type; /* The message type-see below for valid types */ 740Sstevel@tonic-gate uint16_t length; /* Length of the whole message. */ 750Sstevel@tonic-gate uint8_t txnum; /* Sequence number of this message. */ 760Sstevel@tonic-gate uint8_t rxnum; /* Highest sequence number received. */ 770Sstevel@tonic-gate /* (AKA piggy-backed acknowledgement). */ 780Sstevel@tonic-gate uint16_t crc; /* CRC-16 Checksum of header. */ 790Sstevel@tonic-gate 800Sstevel@tonic-gate } dp_header_t; 810Sstevel@tonic-gate 820Sstevel@tonic-gate /* 830Sstevel@tonic-gate * Macros for dealing with sequence id's. 840Sstevel@tonic-gate */ 850Sstevel@tonic-gate 860Sstevel@tonic-gate /* Given a sequence id, calculate the next one. */ 870Sstevel@tonic-gate #define NEXT_SEQID(a) (((a) + 1) % 0x100) 880Sstevel@tonic-gate 890Sstevel@tonic-gate /* Given a sequence id, calculate the previous one. */ 900Sstevel@tonic-gate #define PREV_SEQID(a) (((a) == 0) ? 0xff : (a)-1) 910Sstevel@tonic-gate 920Sstevel@tonic-gate /* Do these sequence ID's follow each other? */ 930Sstevel@tonic-gate #define IS_NEXT_SEQID(a, b) ((b) == NEXT_SEQID(a)) 940Sstevel@tonic-gate 950Sstevel@tonic-gate /* What to initialize sequence ID counters to. */ 960Sstevel@tonic-gate #define INITIAL_SEQID 0xFF 970Sstevel@tonic-gate 980Sstevel@tonic-gate /* 990Sstevel@tonic-gate * Macros for interpreting message types. 1000Sstevel@tonic-gate */ 1010Sstevel@tonic-gate #define IS_NUMBERED_MSG(t) (((t) & 0x80) == 0x00) 1020Sstevel@tonic-gate #define IS_UNNUMBERED_MSG(t) (((t) & 0xC0) == 0x80) 1030Sstevel@tonic-gate #define IS_BOOT_MSG(t) (((t) & 0xE0) == 0xC0) 1040Sstevel@tonic-gate 1050Sstevel@tonic-gate /* 1060Sstevel@tonic-gate * Un-numbered messages. 1070Sstevel@tonic-gate */ 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate #define DP_CTL_START 0x88 1100Sstevel@tonic-gate 1110Sstevel@tonic-gate #define DP_CTL_STACK 0x89 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate #define DP_CTL_RESPOND 0x8A 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate #define DP_CTL_ACK 0x8B 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate #define DP_CTL_NAK 0x8C 1180Sstevel@tonic-gate 1190Sstevel@tonic-gate #ifdef __cplusplus 1200Sstevel@tonic-gate } 1210Sstevel@tonic-gate #endif 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate #endif /* _SYS_RMC_COMM_LPROTO_H */ 124