xref: /titanic_41/usr/src/lib/libpcp/common/pcp_common.h (revision 1816cb7076d3ec8a78ef9ac9f895574e13c43645)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_PCP_COMMON_H
28 #define	_PCP_COMMON_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * This file is shared by both ALOM and Solaris sides of
38  * Platform Channel Protocol users. So this file should
39  * include only common shared things.
40  */
41 
42 /*
43  * Platform Channel Request Message Header.
44  */
45 typedef struct pcp_req_msg_hdr {
46 	uint32_t	magic_num;	/* magic number */
47 	uint8_t		proto_ver;	/* version info for */
48 					/* backward compatibility */
49 	uint8_t		msg_type;	/* provided by user apps */
50 	uint8_t		sub_type;	/* provided by user apps */
51 	uint8_t		rsvd_pad;	/* padding bits */
52 	uint32_t	xid;		/* transaction id */
53 	uint32_t	timeout;	/* timeout in seconds */
54 	uint32_t	msg_len;	/* length of request or response data */
55 	uint16_t	msg_cksum;	/* 16-bit checksum of req msg data */
56 	uint16_t	hdr_cksum;	/* 16-bit checksum of req hdr */
57 } pcp_req_msg_hdr_t;
58 
59 
60 /*
61  * Platform Channel Response Message Header.
62  */
63 typedef struct pcp_resp_msg_hdr {
64 	uint32_t 	magic_num;	/* magic number */
65 	uint8_t		proto_ver;	/* version info for */
66 					/* backward compatibility */
67 	uint8_t		msg_type;	/* passed to user apps */
68 	uint8_t		sub_type;	/* passed to user apps */
69 	uint8_t		rsvd_pad;	/* for padding */
70 	uint32_t	xid;		/* transaction id */
71 	uint32_t	timeout;	/* timeout in seconds */
72 	uint32_t	msg_len;	/* length of request or response data */
73 	uint32_t	status;		/* response status */
74 	uint16_t	msg_cksum;	/* 16-bit checksum of resp msg data */
75 	uint16_t	hdr_cksum;	/* 16-bit checksum of resp hdr */
76 } pcp_resp_msg_hdr_t;
77 
78 /*
79  * magic number for Platform Channel Protocol (PCP)
80  * ~(rot13("PCP_") = 0xAFBCAFA0
81  * rot13 is a simple Caesar-cypher encryption that replaces each English letter
82  * with the one 13 places forward or back along the alphabet.
83  */
84 #define	PCP_MAGIC_NUM		(0xAFBCAFA0)
85 
86 
87 /* Platform channel protocol versions. */
88 #define	PCP_PROT_VER_1		1
89 
90 
91 /* Error codes for 'status' field in response message header */
92 
93 #define	PCP_OK			(0)	/* message received okay */
94 #define	PCP_ERROR		(1)	/* generic error */
95 #define	PCP_HDR_CKSUM_ERROR	(2)	/* header checksum error */
96 #define	PCP_MSG_CKSUM_ERROR	(3)	/* message checksum error */
97 #define	PCP_XPORT_ERROR		(4)	/* message in complete error */
98 
99 /* defines for 'timeout' */
100 #define	PCP_TO_NO_RESPONSE	(0xFFFFFFFF)	/* no response required */
101 #define	PCP_TO_WAIT_FOREVER	(0)	/* wait forever..(in reality, */
102 					/* it waits until glvc driver */
103 					/* call returns; curently glvc */
104 					/* calls are blocking calls. */
105 
106 #ifdef	__cplusplus
107 }
108 #endif
109 
110 #endif /* _PCP_COMMON_H */
111