11531Skini /* 21531Skini * CDDL HEADER START 31531Skini * 41531Skini * The contents of this file are subject to the terms of the 5*1540Skini * Common Development and Distribution License (the "License"). 6*1540Skini * You may not use this file except in compliance with the License. 71531Skini * 81531Skini * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 91531Skini * or http://www.opensolaris.org/os/licensing. 101531Skini * See the License for the specific language governing permissions 111531Skini * and limitations under the License. 121531Skini * 131531Skini * When distributing Covered Code, include this CDDL HEADER in each 141531Skini * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 151531Skini * If applicable, add the following below this CDDL HEADER, with the 161531Skini * fields enclosed by brackets "[]" replaced with your own identifying 171531Skini * information: Portions Copyright [yyyy] [name of copyright owner] 181531Skini * 191531Skini * CDDL HEADER END 201531Skini */ 211531Skini /* 22*1540Skini * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 231531Skini * Use is subject to license terms. 241531Skini */ 251531Skini 261531Skini #ifndef _SYS_FC_PLAT_H 271531Skini #define _SYS_FC_PLAT_H 281531Skini 291531Skini #pragma ident "%Z%%M% %I% %E% SMI" 301531Skini 311531Skini #include <sys/inttypes.h> 321531Skini #include <sys/obpdefs.h> 331531Skini 341531Skini #ifdef __cplusplus 351531Skini extern "C" { 361531Skini #endif 371531Skini 381531Skini /* 391531Skini * Platform specific definitions for the fcode interpreter and driver. 401531Skini * Define the cell size for the implementation. 411531Skini * 421531Skini * These definitions are appropriate for SPARC V9. 431531Skini */ 441531Skini 451531Skini /* 461531Skini * The cell size is based on the cell size of the underlying "firmware" 471531Skini * implementation. NB: FCode is really a 32-bit language, but we still 481531Skini * define our interfaces in terms of the underlying cell size. 491531Skini */ 501531Skini 511531Skini typedef unsigned long long fc_cell_t; 521531Skini 531531Skini /* 541531Skini * common typedef for phandles accross the interface. 551531Skini */ 561531Skini typedef uint32_t fc_phandle_t; 571531Skini 581531Skini /* 591531Skini * Handy macros for converting from an fc_cell_t to an integral type 601531Skini * These are useful because arguments and results are always passed 611531Skini * in an array of fc_cell_t's. 621531Skini */ 631531Skini 641531Skini #define fc_ptr2cell(p) ((fc_cell_t)((uintptr_t)((void *)(p)))) 651531Skini #define fc_int2cell(i) ((fc_cell_t)((int)(i))) 661531Skini #define fc_uint2cell(u) ((fc_cell_t)((unsigned int)(u))) 671531Skini #define fc_uint32_t2cell(u) ((fc_cell_t)((unsigned int)((uint32_t)(u)))) 681531Skini #define fc_uint16_t2cell(w) ((fc_cell_t)((unsigned int)((uint16_t)(w)))) 691531Skini #define fc_uint8_t2cell(b) ((fc_cell_t)((unsigned int)((uint8_t)(b)))) 701531Skini #define fc_size2cell(u) ((fc_cell_t)((size_t)(u))) 711531Skini #define fc_ssize2cell(i) ((fc_cell_t)((ssize_t)(i))) 721531Skini #define fc_phandle2cell(ph) ((fc_cell_t)((unsigned int)((phandle_t)(ph)))) 731531Skini #define fc_dnode2cell(d) ((fc_cell_t)((unsigned int)((pnode_t)(d)))) 741531Skini #define fc_ull2cell_high(ll) (0LL) 751531Skini #define fc_ull2cell_low(ll) ((fc_cell_t)(ll)) 761531Skini #define fc_uintptr2cell(i) ((fc_cell_t)((uintptr_t)(i))) 771531Skini #define fc_uchar2cell(c) ((fc_cell_t)((unsigned char)(c))) 781531Skini #define fc_ushort2cell(w) ((fc_cell_t)((unsigned short)(w))) 791531Skini #define fc_ihandle2cell(h) ((fc_cell_t)((fc_ihandle_t)(h))) 801531Skini 811531Skini #define fc_cell2ptr(p) ((void *)((fc_cell_t)(p))) 821531Skini #define fc_cell2int(i) ((int)((fc_cell_t)(i))) 831531Skini #define fc_cell2uint(u) ((unsigned int)((fc_cell_t)(u))) 841531Skini #define fc_cell2uint32_t(u) ((uint32_t)((fc_cell_t)(u))) 851531Skini #define fc_cell2uint16_t(w) ((uint16_t)((fc_cell_t)(w))) 861531Skini #define fc_cell2uint8_t(b) ((uint8_t)((fc_cell_t)(b))) 871531Skini #define fc_cell2size(u) ((size_t)((fc_cell_t)(u))) 881531Skini #define fc_cell2ssize(i) ((ssize_t)((fc_cell_t)(i))) 891531Skini #define fc_cell2phandle(ph) ((phandle_t)((fc_cell_t)(ph))) 901531Skini #define fc_cell2dnode(d) ((pnode_t)((fc_cell_t)(d))) 911531Skini #define fc_cells2ull(h, l) ((unsigned long long)(fc_cell_t)(l)) 921531Skini #define fc_cell2uintptr(i) ((uintptr_t)((fc_cell_t)(i))) 931531Skini #define fc_cell2uchar(c) ((unsigned char)(fc_cell_t)(c)) 941531Skini #define fc_cell2ushort(w) ((unsigned short)(fc_cell_t)(w)) 951531Skini #define fc_cell2ihandle(h) ((fc_ihandle_t)(fc_cell_t)(h)) 961531Skini 971531Skini #ifdef __cplusplus 981531Skini } 991531Skini #endif 1001531Skini 1011531Skini #endif /* _SYS_FC_PLAT_H */ 102