/* * ========== Copyright Header Begin ========================================== * * OpenSPARC T2 Processor File: Pfe_Conversion.i * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. * * The above named program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License version 2 as published by the Free Software Foundation. * * The above named program is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this work; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * * ========== Copyright Header End ============================================ */ %module Pfe_Conversion %{ #include #include "BL_Endian.h" #include "Pfe_HexDec.h" %} /* Switch default print in hexadecimal (hexmode) or decimal (decmode = default) */ typedef unsigned short uint16_t; typedef unsigned uint32_t; typedef unsigned long long uint64_t; void decmode(); void hexmode(); %inline %{ /* Floating point to integer conversion for x,d(64bit) w,f (32bit) */ float w2f( uint64_t w ) { uint32_t _w = w; return *(float*)&_w; } uint32_t f2w( float f ) { return *(uint32_t*)&f; } double x2d( uint64_t x ) { return *(double*)&x; } uint64_t d2x( double d ) { return *(uint64_t*)&d; } /* Endian conversion functions for x(64bit) w(32bit) and h(16bit) */ uint64_t x2x( uint64_t x ) { return endianess_convert_64(x); } uint32_t w2w( uint64_t w ) { return endianess_convert_32u(w); } uint16_t h2h( uint16_t h ) { return endianess_convert_16u(h); } %}