17c478bd9Sstevel@tonic-gate /*
2*8d96d5b3Sjroberts  * CDDL HEADER START
3*8d96d5b3Sjroberts  *
4*8d96d5b3Sjroberts  * The contents of this file are subject to the terms of the
5*8d96d5b3Sjroberts  * Common Development and Distribution License (the "License").
6*8d96d5b3Sjroberts  * You may not use this file except in compliance with the License.
7*8d96d5b3Sjroberts  *
8*8d96d5b3Sjroberts  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*8d96d5b3Sjroberts  * or http://www.opensolaris.org/os/licensing.
10*8d96d5b3Sjroberts  * See the License for the specific language governing permissions
11*8d96d5b3Sjroberts  * and limitations under the License.
12*8d96d5b3Sjroberts  *
13*8d96d5b3Sjroberts  * When distributing Covered Code, include this CDDL HEADER in each
14*8d96d5b3Sjroberts  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*8d96d5b3Sjroberts  * If applicable, add the following below this CDDL HEADER, with the
16*8d96d5b3Sjroberts  * fields enclosed by brackets "[]" replaced with your own identifying
17*8d96d5b3Sjroberts  * information: Portions Copyright [yyyy] [name of copyright owner]
18*8d96d5b3Sjroberts  *
19*8d96d5b3Sjroberts  * CDDL HEADER END
20*8d96d5b3Sjroberts  */
21*8d96d5b3Sjroberts 
22*8d96d5b3Sjroberts /*
23*8d96d5b3Sjroberts  * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_SYS_RMC_COMM_LPROTO_H
287c478bd9Sstevel@tonic-gate #define	_SYS_RMC_COMM_LPROTO_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
337c478bd9Sstevel@tonic-gate extern "C" {
347c478bd9Sstevel@tonic-gate #endif
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #define	SYNC_CHAR	0x80
377c478bd9Sstevel@tonic-gate #define	ESC_CHAR	0x81
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /* Maximum message length */
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate #define	DP_MAX_MSGLEN	1024
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate /*
447c478bd9Sstevel@tonic-gate  * Tunables.
457c478bd9Sstevel@tonic-gate  */
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate /* Number of times a transmitted message will be retried. */
487c478bd9Sstevel@tonic-gate #define	TX_RETRIES	10
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate /* Amount of time between transmit retries in ms, currently 500ms. */
517c478bd9Sstevel@tonic-gate #define	TX_RETRY_TIME	500L
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate /* minimum waiting time for a reply (milliseconds) */
547c478bd9Sstevel@tonic-gate #define	DP_MIN_TIMEOUT	200L
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  * timeout (in ms) for (re)trying to establish the protocol data link
587c478bd9Sstevel@tonic-gate  */
597c478bd9Sstevel@tonic-gate #define	DELAY_DP_SETUP		10
607c478bd9Sstevel@tonic-gate #define	RETRY_DP_SETUP		5000
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate /*
637c478bd9Sstevel@tonic-gate  * Data protocol message structure.  Note that this is the in-memory
647c478bd9Sstevel@tonic-gate  * version; when a data protocol message is transmitted it goes
657c478bd9Sstevel@tonic-gate  * through a translation to assist the receiving side in determining
667c478bd9Sstevel@tonic-gate  * message boundaries robustly.
677c478bd9Sstevel@tonic-gate  */
687c478bd9Sstevel@tonic-gate typedef struct dp_header {
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate 	uint8_t  pad;		/* This pad byte is never transmitted nor */
717c478bd9Sstevel@tonic-gate 				/* received, it is solely to make the */
727c478bd9Sstevel@tonic-gate 				/* structure elements line up in memory. */
737c478bd9Sstevel@tonic-gate 	uint8_t  type;		/* The message type-see below for valid types */
747c478bd9Sstevel@tonic-gate 	uint16_t length;	/* Length of the whole message. */
757c478bd9Sstevel@tonic-gate 	uint8_t  txnum;		/* Sequence number of this message. */
767c478bd9Sstevel@tonic-gate 	uint8_t  rxnum;		/* Highest sequence number received. */
777c478bd9Sstevel@tonic-gate 				/* (AKA piggy-backed acknowledgement). */
787c478bd9Sstevel@tonic-gate 	uint16_t crc;		/* CRC-16 Checksum of header. */
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate } dp_header_t;
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate /*
837c478bd9Sstevel@tonic-gate  * Macros for dealing with sequence id's.
847c478bd9Sstevel@tonic-gate  */
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate /* Given a sequence id, calculate the next one. */
877c478bd9Sstevel@tonic-gate #define	NEXT_SEQID(a)		(((a) + 1) % 0x100)
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate /* Given a sequence id, calculate the previous one. */
907c478bd9Sstevel@tonic-gate #define	PREV_SEQID(a)		(((a) == 0) ? 0xff : (a)-1)
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate /* Do these sequence ID's follow each other? */
937c478bd9Sstevel@tonic-gate #define	IS_NEXT_SEQID(a, b)	((b) == NEXT_SEQID(a))
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate /* What to initialize sequence ID counters to. */
967c478bd9Sstevel@tonic-gate #define	INITIAL_SEQID		0xFF
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate /*
997c478bd9Sstevel@tonic-gate  * Macros for interpreting message types.
1007c478bd9Sstevel@tonic-gate  */
1017c478bd9Sstevel@tonic-gate #define	IS_NUMBERED_MSG(t)	(((t) & 0x80) == 0x00)
1027c478bd9Sstevel@tonic-gate #define	IS_UNNUMBERED_MSG(t)	(((t) & 0xC0) == 0x80)
1037c478bd9Sstevel@tonic-gate #define	IS_BOOT_MSG(t)		(((t) & 0xE0) == 0xC0)
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate /*
1067c478bd9Sstevel@tonic-gate  * Un-numbered messages.
1077c478bd9Sstevel@tonic-gate  */
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate #define	DP_CTL_START		0x88
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate #define	DP_CTL_STACK		0x89
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate #define	DP_CTL_RESPOND		0x8A
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate #define	DP_CTL_ACK		0x8B
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate #define	DP_CTL_NAK		0x8C
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1207c478bd9Sstevel@tonic-gate }
1217c478bd9Sstevel@tonic-gate #endif
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate #endif	/* _SYS_RMC_COMM_LPROTO_H */
124