xref: /titanic_51/usr/src/lib/libpcp/common/pcp_common.h (revision 5db09ef5a5ba16a4728800a9055f47b3f404a2b3)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2005 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	_PCP_COMMON_H
287c478bd9Sstevel@tonic-gate #define	_PCP_COMMON_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 /*
377c478bd9Sstevel@tonic-gate  * This file is shared by both ALOM and Solaris sides of
387c478bd9Sstevel@tonic-gate  * Platform Channel Protocol users. So this file should
397c478bd9Sstevel@tonic-gate  * include only common shared things.
407c478bd9Sstevel@tonic-gate  */
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * Platform Channel Request Message Header.
447c478bd9Sstevel@tonic-gate  */
457c478bd9Sstevel@tonic-gate typedef struct pcp_req_msg_hdr {
467c478bd9Sstevel@tonic-gate 	uint32_t	magic_num;	/* magic number */
477c478bd9Sstevel@tonic-gate 	uint8_t		proto_ver;	/* version info for */
487c478bd9Sstevel@tonic-gate 					/* backward compatibility */
497c478bd9Sstevel@tonic-gate 	uint8_t		msg_type;	/* provided by user apps */
507c478bd9Sstevel@tonic-gate 	uint8_t		sub_type;	/* provided by user apps */
517c478bd9Sstevel@tonic-gate 	uint8_t		rsvd_pad;	/* padding bits */
527c478bd9Sstevel@tonic-gate 	uint32_t	xid;		/* transaction id */
537c478bd9Sstevel@tonic-gate 	uint32_t	timeout;	/* timeout in seconds */
547c478bd9Sstevel@tonic-gate 	uint32_t	msg_len;	/* length of request or response data */
557c478bd9Sstevel@tonic-gate 	uint16_t	msg_cksum;	/* 16-bit checksum of req msg data */
567c478bd9Sstevel@tonic-gate 	uint16_t	hdr_cksum;	/* 16-bit checksum of req hdr */
577c478bd9Sstevel@tonic-gate } pcp_req_msg_hdr_t;
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate /*
617c478bd9Sstevel@tonic-gate  * Platform Channel Response Message Header.
627c478bd9Sstevel@tonic-gate  */
637c478bd9Sstevel@tonic-gate typedef struct pcp_resp_msg_hdr {
647c478bd9Sstevel@tonic-gate 	uint32_t 	magic_num;	/* magic number */
657c478bd9Sstevel@tonic-gate 	uint8_t		proto_ver;	/* version info for */
667c478bd9Sstevel@tonic-gate 					/* backward compatibility */
677c478bd9Sstevel@tonic-gate 	uint8_t		msg_type;	/* passed to user apps */
687c478bd9Sstevel@tonic-gate 	uint8_t		sub_type;	/* passed to user apps */
697c478bd9Sstevel@tonic-gate 	uint8_t		rsvd_pad;	/* for padding */
707c478bd9Sstevel@tonic-gate 	uint32_t	xid;		/* transaction id */
717c478bd9Sstevel@tonic-gate 	uint32_t	timeout;	/* timeout in seconds */
727c478bd9Sstevel@tonic-gate 	uint32_t	msg_len;	/* length of request or response data */
737c478bd9Sstevel@tonic-gate 	uint32_t	status;		/* response status */
747c478bd9Sstevel@tonic-gate 	uint16_t	msg_cksum;	/* 16-bit checksum of resp msg data */
757c478bd9Sstevel@tonic-gate 	uint16_t	hdr_cksum;	/* 16-bit checksum of resp hdr */
767c478bd9Sstevel@tonic-gate } pcp_resp_msg_hdr_t;
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate /*
797c478bd9Sstevel@tonic-gate  * magic number for Platform Channel Protocol (PCP)
807c478bd9Sstevel@tonic-gate  * ~(rot13("PCP_") = 0xAFBCAFA0
817c478bd9Sstevel@tonic-gate  * rot13 is a simple Caesar-cypher encryption that replaces each English letter
827c478bd9Sstevel@tonic-gate  * with the one 13 places forward or back along the alphabet.
837c478bd9Sstevel@tonic-gate  */
847c478bd9Sstevel@tonic-gate #define	PCP_MAGIC_NUM		(0xAFBCAFA0)
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate /* Platform channel protocol versions. */
887c478bd9Sstevel@tonic-gate #define	PCP_PROT_VER_1		1
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate /* Error codes for 'status' field in response message header */
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate #define	PCP_OK			(0)	/* message received okay */
947c478bd9Sstevel@tonic-gate #define	PCP_ERROR		(1)	/* generic error */
957c478bd9Sstevel@tonic-gate #define	PCP_HDR_CKSUM_ERROR	(2)	/* header checksum error */
967c478bd9Sstevel@tonic-gate #define	PCP_MSG_CKSUM_ERROR	(3)	/* message checksum error */
977c478bd9Sstevel@tonic-gate #define	PCP_XPORT_ERROR		(4)	/* message in complete error */
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate /* defines for 'timeout' */
100*5db09ef5Smvgr #define	PCP_TO_NO_RESPONSE	(0xFFFFFFFF)	/* no response required */
1017c478bd9Sstevel@tonic-gate #define	PCP_TO_WAIT_FOREVER	(0)	/* wait forever..(in reality, */
1027c478bd9Sstevel@tonic-gate 					/* it waits until glvc driver */
1037c478bd9Sstevel@tonic-gate 					/* call returns; curently glvc */
1047c478bd9Sstevel@tonic-gate 					/* calls are blocking calls. */
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1077c478bd9Sstevel@tonic-gate }
1087c478bd9Sstevel@tonic-gate #endif
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate #endif /* _PCP_COMMON_H */
111