1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2002 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_RMC_COMM_LPROTO_H 28 #define _SYS_RMC_COMM_LPROTO_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #define SYNC_CHAR 0x80 37 #define ESC_CHAR 0x81 38 39 /* Maximum message length */ 40 41 #define DP_MAX_MSGLEN 1024 42 43 /* 44 * Tunables. 45 */ 46 47 /* Number of times a transmitted message will be retried. */ 48 #define TX_RETRIES 10 49 50 /* Amount of time between transmit retries in ms, currently 500ms. */ 51 #define TX_RETRY_TIME 500L 52 53 /* minimum waiting time for a reply (milliseconds) */ 54 #define DP_MIN_TIMEOUT 200L 55 56 /* 57 * timeout (in ms) for (re)trying to establish the protocol data link 58 */ 59 #define DELAY_DP_SETUP 10 60 #define RETRY_DP_SETUP 5000 61 62 /* 63 * Data protocol message structure. Note that this is the in-memory 64 * version; when a data protocol message is transmitted it goes 65 * through a translation to assist the receiving side in determining 66 * message boundaries robustly. 67 */ 68 typedef struct dp_header { 69 70 uint8_t pad; /* This pad byte is never transmitted nor */ 71 /* received, it is solely to make the */ 72 /* structure elements line up in memory. */ 73 uint8_t type; /* The message type-see below for valid types */ 74 uint16_t length; /* Length of the whole message. */ 75 uint8_t txnum; /* Sequence number of this message. */ 76 uint8_t rxnum; /* Highest sequence number received. */ 77 /* (AKA piggy-backed acknowledgement). */ 78 uint16_t crc; /* CRC-16 Checksum of header. */ 79 80 } dp_header_t; 81 82 /* 83 * Macros for dealing with sequence id's. 84 */ 85 86 /* Given a sequence id, calculate the next one. */ 87 #define NEXT_SEQID(a) (((a) + 1) % 0x100) 88 89 /* Given a sequence id, calculate the previous one. */ 90 #define PREV_SEQID(a) (((a) == 0) ? 0xff : (a)-1) 91 92 /* Do these sequence ID's follow each other? */ 93 #define IS_NEXT_SEQID(a, b) ((b) == NEXT_SEQID(a)) 94 95 /* What to initialize sequence ID counters to. */ 96 #define INITIAL_SEQID 0xFF 97 98 /* 99 * Macros for interpreting message types. 100 */ 101 #define IS_NUMBERED_MSG(t) (((t) & 0x80) == 0x00) 102 #define IS_UNNUMBERED_MSG(t) (((t) & 0xC0) == 0x80) 103 #define IS_BOOT_MSG(t) (((t) & 0xE0) == 0xC0) 104 105 /* 106 * Un-numbered messages. 107 */ 108 109 #define DP_CTL_START 0x88 110 111 #define DP_CTL_STACK 0x89 112 113 #define DP_CTL_RESPOND 0x8A 114 115 #define DP_CTL_ACK 0x8B 116 117 #define DP_CTL_NAK 0x8C 118 119 #ifdef __cplusplus 120 } 121 #endif 122 123 #endif /* _SYS_RMC_COMM_LPROTO_H */ 124