xref: /titanic_50/usr/src/uts/sun4u/sys/rmc_comm_lproto.h (revision 554ff184129088135ad2643c1c9832174a17be88)
1 /*
2  * Copyright 2001-2002 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 #ifndef	_SYS_RMC_COMM_LPROTO_H
7 #define	_SYS_RMC_COMM_LPROTO_H
8 
9 #pragma ident	"%Z%%M%	%I%	%E% SMI"
10 
11 #ifdef	__cplusplus
12 extern "C" {
13 #endif
14 
15 #define	SYNC_CHAR	0x80
16 #define	ESC_CHAR	0x81
17 
18 /* Maximum message length */
19 
20 #define	DP_MAX_MSGLEN	1024
21 
22 /*
23  * Tunables.
24  */
25 
26 /* Number of times a transmitted message will be retried. */
27 #define	TX_RETRIES	10
28 
29 /* Amount of time between transmit retries in ms, currently 500ms. */
30 #define	TX_RETRY_TIME	500L
31 
32 /* minimum waiting time for a reply (milliseconds) */
33 #define	DP_MIN_TIMEOUT	200L
34 
35 /*
36  * timeout (in ms) for (re)trying to establish the protocol data link
37  */
38 #define	DELAY_DP_SETUP		10
39 #define	RETRY_DP_SETUP		5000
40 
41 /*
42  * Data protocol message structure.  Note that this is the in-memory
43  * version; when a data protocol message is transmitted it goes
44  * through a translation to assist the receiving side in determining
45  * message boundaries robustly.
46  */
47 typedef struct dp_header {
48 
49 	uint8_t  pad;		/* This pad byte is never transmitted nor */
50 				/* received, it is solely to make the */
51 				/* structure elements line up in memory. */
52 	uint8_t  type;		/* The message type-see below for valid types */
53 	uint16_t length;	/* Length of the whole message. */
54 	uint8_t  txnum;		/* Sequence number of this message. */
55 	uint8_t  rxnum;		/* Highest sequence number received. */
56 				/* (AKA piggy-backed acknowledgement). */
57 	uint16_t crc;		/* CRC-16 Checksum of header. */
58 
59 } dp_header_t;
60 
61 /*
62  * Macros for dealing with sequence id's.
63  */
64 
65 /* Given a sequence id, calculate the next one. */
66 #define	NEXT_SEQID(a)		(((a) + 1) % 0x100)
67 
68 /* Given a sequence id, calculate the previous one. */
69 #define	PREV_SEQID(a)		(((a) == 0) ? 0xff : (a)-1)
70 
71 /* Do these sequence ID's follow each other? */
72 #define	IS_NEXT_SEQID(a, b)	((b) == NEXT_SEQID(a))
73 
74 /* What to initialize sequence ID counters to. */
75 #define	INITIAL_SEQID		0xFF
76 
77 /*
78  * Macros for interpreting message types.
79  */
80 #define	IS_NUMBERED_MSG(t)	(((t) & 0x80) == 0x00)
81 #define	IS_UNNUMBERED_MSG(t)	(((t) & 0xC0) == 0x80)
82 #define	IS_BOOT_MSG(t)		(((t) & 0xE0) == 0xC0)
83 
84 /*
85  * Un-numbered messages.
86  */
87 
88 #define	DP_CTL_START		0x88
89 
90 #define	DP_CTL_STACK		0x89
91 
92 #define	DP_CTL_RESPOND		0x8A
93 
94 #define	DP_CTL_ACK		0x8B
95 
96 #define	DP_CTL_NAK		0x8C
97 
98 #ifdef	__cplusplus
99 }
100 #endif
101 
102 #endif	/* _SYS_RMC_COMM_LPROTO_H */
103