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