Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: Pfe_Conversion.i | |
5 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
7 | * | |
8 | * The above named program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public | |
10 | * License version 2 as published by the Free Software Foundation. | |
11 | * | |
12 | * The above named program is distributed in the hope that it will be | |
13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public | |
18 | * License along with this work; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | * | |
21 | * ========== Copyright Header End ============================================ | |
22 | */ | |
23 | %module Pfe_Conversion | |
24 | ||
25 | %{ | |
26 | #include <sys/types.h> | |
27 | #include "BL_Endian.h" | |
28 | #include "Pfe_HexDec.h" | |
29 | %} | |
30 | ||
31 | /* Switch default print in hexadecimal (hexmode) or decimal (decmode = default) */ | |
32 | ||
33 | typedef unsigned short uint16_t; | |
34 | typedef unsigned uint32_t; | |
35 | typedef unsigned long long uint64_t; | |
36 | ||
37 | void decmode(); | |
38 | void hexmode(); | |
39 | ||
40 | %inline %{ | |
41 | ||
42 | /* Floating point to integer conversion for x,d(64bit) w,f (32bit) */ | |
43 | ||
44 | float w2f( uint64_t w ) { uint32_t _w = w; return *(float*)&_w; } | |
45 | uint32_t f2w( float f ) { return *(uint32_t*)&f; } | |
46 | ||
47 | double x2d( uint64_t x ) { return *(double*)&x; } | |
48 | uint64_t d2x( double d ) { return *(uint64_t*)&d; } | |
49 | ||
50 | /* Endian conversion functions for x(64bit) w(32bit) and h(16bit) */ | |
51 | ||
52 | uint64_t x2x( uint64_t x ) | |
53 | { | |
54 | return endianess_convert_64(x); | |
55 | } | |
56 | ||
57 | uint32_t w2w( uint64_t w ) | |
58 | { | |
59 | return endianess_convert_32u(w); | |
60 | } | |
61 | ||
62 | uint16_t h2h( uint16_t h ) | |
63 | { | |
64 | return endianess_convert_16u(h); | |
65 | } | |
66 | ||
67 | %} |