xref: /titanic_52/usr/src/uts/sun4/sys/fc_plat.h (revision 2b24ab6b3865caeede9eeb9db6b83e1d89dcd1ea)
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  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_FC_PLAT_H
27 #define	_SYS_FC_PLAT_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/inttypes.h>
32 #include <sys/obpdefs.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * Platform specific definitions for the fcode interpreter and driver.
40  * Define the cell size for the implementation.
41  *
42  * These definitions are appropriate for SPARC V9.
43  */
44 
45 /*
46  * The cell size is based on the cell size of the underlying "firmware"
47  * implementation.  NB: FCode is really a 32-bit language, but we still
48  * define our interfaces in terms of the underlying cell size.
49  */
50 
51 typedef unsigned long long fc_cell_t;
52 
53 /*
54  * common typedef for phandles accross the interface.
55  */
56 typedef uint32_t fc_phandle_t;
57 
58 /*
59  * Handy macros for converting from an fc_cell_t to an integral type
60  * These are useful because arguments and results are always passed
61  * in an array of fc_cell_t's.
62  */
63 
64 #define	fc_ptr2cell(p)		((fc_cell_t)((uintptr_t)((void *)(p))))
65 #define	fc_int2cell(i)		((fc_cell_t)((int)(i)))
66 #define	fc_uint2cell(u)		((fc_cell_t)((unsigned int)(u)))
67 #define	fc_uint32_t2cell(u)	((fc_cell_t)((unsigned int)((uint32_t)(u))))
68 #define	fc_uint16_t2cell(w)	((fc_cell_t)((unsigned int)((uint16_t)(w))))
69 #define	fc_uint8_t2cell(b)	((fc_cell_t)((unsigned int)((uint8_t)(b))))
70 #define	fc_size2cell(u)		((fc_cell_t)((size_t)(u)))
71 #define	fc_ssize2cell(i)	((fc_cell_t)((ssize_t)(i)))
72 #define	fc_phandle2cell(ph)	((fc_cell_t)((unsigned int)((phandle_t)(ph))))
73 #define	fc_dnode2cell(d)	((fc_cell_t)((unsigned int)((pnode_t)(d))))
74 #define	fc_ull2cell_high(ll)	(0LL)
75 #define	fc_ull2cell_low(ll)	((fc_cell_t)(ll))
76 #define	fc_uintptr2cell(i)	((fc_cell_t)((uintptr_t)(i)))
77 #define	fc_uchar2cell(c)	((fc_cell_t)((unsigned char)(c)))
78 #define	fc_ushort2cell(w)	((fc_cell_t)((unsigned short)(w)))
79 #define	fc_ihandle2cell(h)	((fc_cell_t)((fc_ihandle_t)(h)))
80 
81 #define	fc_cell2ptr(p)		((void *)((fc_cell_t)(p)))
82 #define	fc_cell2int(i)		((int)((fc_cell_t)(i)))
83 #define	fc_cell2uint(u)		((unsigned int)((fc_cell_t)(u)))
84 #define	fc_cell2uint32_t(u)	((uint32_t)((fc_cell_t)(u)))
85 #define	fc_cell2uint16_t(w)	((uint16_t)((fc_cell_t)(w)))
86 #define	fc_cell2uint8_t(b)	((uint8_t)((fc_cell_t)(b)))
87 #define	fc_cell2size(u)		((size_t)((fc_cell_t)(u)))
88 #define	fc_cell2ssize(i)	((ssize_t)((fc_cell_t)(i)))
89 #define	fc_cell2phandle(ph)	((phandle_t)((fc_cell_t)(ph)))
90 #define	fc_cell2dnode(d)	((pnode_t)((fc_cell_t)(d)))
91 #define	fc_cells2ull(h, l)	((unsigned long long)(fc_cell_t)(l))
92 #define	fc_cell2uintptr(i)	((uintptr_t)((fc_cell_t)(i)))
93 #define	fc_cell2uchar(c)	((unsigned char)(fc_cell_t)(c))
94 #define	fc_cell2ushort(w)	((unsigned short)(fc_cell_t)(w))
95 #define	fc_cell2ihandle(h)	((fc_ihandle_t)(fc_cell_t)(h))
96 
97 #ifdef	__cplusplus
98 }
99 #endif
100 
101 #endif /* _SYS_FC_PLAT_H */
102