1b65731f1Skini /* 2b65731f1Skini * CDDL HEADER START 3b65731f1Skini * 4b65731f1Skini * The contents of this file are subject to the terms of the 5*7aadd8d4Skini * Common Development and Distribution License (the "License"). 6*7aadd8d4Skini * You may not use this file except in compliance with the License. 7b65731f1Skini * 8b65731f1Skini * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9b65731f1Skini * or http://www.opensolaris.org/os/licensing. 10b65731f1Skini * See the License for the specific language governing permissions 11b65731f1Skini * and limitations under the License. 12b65731f1Skini * 13b65731f1Skini * When distributing Covered Code, include this CDDL HEADER in each 14b65731f1Skini * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15b65731f1Skini * If applicable, add the following below this CDDL HEADER, with the 16b65731f1Skini * fields enclosed by brackets "[]" replaced with your own identifying 17b65731f1Skini * information: Portions Copyright [yyyy] [name of copyright owner] 18b65731f1Skini * 19b65731f1Skini * CDDL HEADER END 20b65731f1Skini */ 21b65731f1Skini /* 22*7aadd8d4Skini * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23b65731f1Skini * Use is subject to license terms. 24b65731f1Skini */ 25b65731f1Skini 26b65731f1Skini #ifndef _SYS_FC_PLAT_H 27b65731f1Skini #define _SYS_FC_PLAT_H 28b65731f1Skini 29b65731f1Skini #pragma ident "%Z%%M% %I% %E% SMI" 30b65731f1Skini 31b65731f1Skini #include <sys/inttypes.h> 32b65731f1Skini #include <sys/obpdefs.h> 33b65731f1Skini 34b65731f1Skini #ifdef __cplusplus 35b65731f1Skini extern "C" { 36b65731f1Skini #endif 37b65731f1Skini 38b65731f1Skini /* 39b65731f1Skini * Platform specific definitions for the fcode interpreter and driver. 40b65731f1Skini * Define the cell size for the implementation. 41b65731f1Skini * 42b65731f1Skini * These definitions are appropriate for SPARC V9. 43b65731f1Skini */ 44b65731f1Skini 45b65731f1Skini /* 46b65731f1Skini * The cell size is based on the cell size of the underlying "firmware" 47b65731f1Skini * implementation. NB: FCode is really a 32-bit language, but we still 48b65731f1Skini * define our interfaces in terms of the underlying cell size. 49b65731f1Skini */ 50b65731f1Skini 51b65731f1Skini typedef unsigned long long fc_cell_t; 52b65731f1Skini 53b65731f1Skini /* 54b65731f1Skini * common typedef for phandles accross the interface. 55b65731f1Skini */ 56b65731f1Skini typedef uint32_t fc_phandle_t; 57b65731f1Skini 58b65731f1Skini /* 59b65731f1Skini * Handy macros for converting from an fc_cell_t to an integral type 60b65731f1Skini * These are useful because arguments and results are always passed 61b65731f1Skini * in an array of fc_cell_t's. 62b65731f1Skini */ 63b65731f1Skini 64b65731f1Skini #define fc_ptr2cell(p) ((fc_cell_t)((uintptr_t)((void *)(p)))) 65b65731f1Skini #define fc_int2cell(i) ((fc_cell_t)((int)(i))) 66b65731f1Skini #define fc_uint2cell(u) ((fc_cell_t)((unsigned int)(u))) 67b65731f1Skini #define fc_uint32_t2cell(u) ((fc_cell_t)((unsigned int)((uint32_t)(u)))) 68b65731f1Skini #define fc_uint16_t2cell(w) ((fc_cell_t)((unsigned int)((uint16_t)(w)))) 69b65731f1Skini #define fc_uint8_t2cell(b) ((fc_cell_t)((unsigned int)((uint8_t)(b)))) 70b65731f1Skini #define fc_size2cell(u) ((fc_cell_t)((size_t)(u))) 71b65731f1Skini #define fc_ssize2cell(i) ((fc_cell_t)((ssize_t)(i))) 72b65731f1Skini #define fc_phandle2cell(ph) ((fc_cell_t)((unsigned int)((phandle_t)(ph)))) 73b65731f1Skini #define fc_dnode2cell(d) ((fc_cell_t)((unsigned int)((pnode_t)(d)))) 74b65731f1Skini #define fc_ull2cell_high(ll) (0LL) 75b65731f1Skini #define fc_ull2cell_low(ll) ((fc_cell_t)(ll)) 76b65731f1Skini #define fc_uintptr2cell(i) ((fc_cell_t)((uintptr_t)(i))) 77b65731f1Skini #define fc_uchar2cell(c) ((fc_cell_t)((unsigned char)(c))) 78b65731f1Skini #define fc_ushort2cell(w) ((fc_cell_t)((unsigned short)(w))) 79b65731f1Skini #define fc_ihandle2cell(h) ((fc_cell_t)((fc_ihandle_t)(h))) 80b65731f1Skini 81b65731f1Skini #define fc_cell2ptr(p) ((void *)((fc_cell_t)(p))) 82b65731f1Skini #define fc_cell2int(i) ((int)((fc_cell_t)(i))) 83b65731f1Skini #define fc_cell2uint(u) ((unsigned int)((fc_cell_t)(u))) 84b65731f1Skini #define fc_cell2uint32_t(u) ((uint32_t)((fc_cell_t)(u))) 85b65731f1Skini #define fc_cell2uint16_t(w) ((uint16_t)((fc_cell_t)(w))) 86b65731f1Skini #define fc_cell2uint8_t(b) ((uint8_t)((fc_cell_t)(b))) 87b65731f1Skini #define fc_cell2size(u) ((size_t)((fc_cell_t)(u))) 88b65731f1Skini #define fc_cell2ssize(i) ((ssize_t)((fc_cell_t)(i))) 89b65731f1Skini #define fc_cell2phandle(ph) ((phandle_t)((fc_cell_t)(ph))) 90b65731f1Skini #define fc_cell2dnode(d) ((pnode_t)((fc_cell_t)(d))) 91b65731f1Skini #define fc_cells2ull(h, l) ((unsigned long long)(fc_cell_t)(l)) 92b65731f1Skini #define fc_cell2uintptr(i) ((uintptr_t)((fc_cell_t)(i))) 93b65731f1Skini #define fc_cell2uchar(c) ((unsigned char)(fc_cell_t)(c)) 94b65731f1Skini #define fc_cell2ushort(w) ((unsigned short)(fc_cell_t)(w)) 95b65731f1Skini #define fc_cell2ihandle(h) ((fc_ihandle_t)(fc_cell_t)(h)) 96b65731f1Skini 97b65731f1Skini #ifdef __cplusplus 98b65731f1Skini } 99b65731f1Skini #endif 100b65731f1Skini 101b65731f1Skini #endif /* _SYS_FC_PLAT_H */ 102