• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/core/techModels/libsim-panalyzer/endian.h

00001 /*
00002  * endian.h - host endian probe interfaces
00003  *
00004  * This file is a part of the SimpleScalar tool suite written by
00005  * Todd M. Austin as a part of the Multiscalar Research Project.
00006  *  
00007  * The tool suite is currently maintained by Doug Burger and Todd M. Austin.
00008  * 
00009  * Copyright (C) 1994, 1995, 1996, 1997, 1998 by Todd M. Austin
00010  *
00011  * This source file is distributed "as is" in the hope that it will be
00012  * useful.  The tool set comes with no warranty, and no author or
00013  * distributor accepts any responsibility for the consequences of its
00014  * use. 
00015  * 
00016  * Everyone is granted permission to copy, modify and redistribute
00017  * this tool set under the following conditions:
00018  * 
00019  *    This source code is distributed for non-commercial use only. 
00020  *    Please contact the maintainer for restrictions applying to 
00021  *    commercial use.
00022  *
00023  *    Permission is granted to anyone to make or distribute copies
00024  *    of this source code, either as received or modified, in any
00025  *    medium, provided that all copyright notices, permission and
00026  *    nonwarranty notices are preserved, and that the distributor
00027  *    grants the recipient permission for further redistribution as
00028  *    permitted by this document.
00029  *
00030  *    Permission is granted to distribute this file in compiled
00031  *    or executable form under the same conditions that apply for
00032  *    source code, provided that either:
00033  *
00034  *    A. it is accompanied by the corresponding machine-readable
00035  *       source code,
00036  *    B. it is accompanied by a written offer, with no time limit,
00037  *       to give anyone a machine-readable copy of the corresponding
00038  *       source code in return for reimbursement of the cost of
00039  *       distribution.  This written offer must permit verbatim
00040  *       duplication by anyone, or
00041  *    C. it is distributed by someone who received only the
00042  *       executable form, and is accompanied by a copy of the
00043  *       written offer of source code that they received concurrently.
00044  *
00045  * In other words, you are welcome to use, share and improve this
00046  * source file.  You are forbidden to forbid anyone else to use, share
00047  * and improve what you give them.
00048  *
00049  * INTERNET: dburger@cs.wisc.edu
00050  * US Mail:  1210 W. Dayton Street, Madison, WI 53706
00051  *
00052  * $Id: endian.h,v 1.1.1.1 2003/09/18 00:57:54 panalyzer Exp $
00053  *
00054  * $Log: endian.h,v $
00055  * Revision 1.1.1.1  2003/09/18 00:57:54  panalyzer
00056  *
00057  *
00058  * Revision 1.1.1.1  2003/09/18 00:18:43  panalyzer
00059  *
00060  *
00061  * Revision 1.1.1.1  2003/09/16 18:48:14  gdm
00062  *
00063  *
00064  * Revision 1.1.1.1  2000/11/29 14:53:54  cu-cs
00065  * Grand unification of arm sources.
00066  *
00067  *
00068  * Revision 1.1.1.1  2000/05/26 15:21:52  taustin
00069  * SimpleScalar Tool Set
00070  *
00071  *
00072  * Revision 1.7  1999/12/31 18:34:59  taustin
00073  * cross-endian execution support added
00074  *
00075  * Revision 1.6  1999/12/13 18:43:19  taustin
00076  * cross endian execution support added
00077  *
00078  * Revision 1.5  1998/08/27 08:25:29  taustin
00079  * implemented host interface description in host.h
00080  *
00081  * Revision 1.4  1997/03/11  01:10:30  taustin
00082  * updated copyright
00083  * long/int tweaks made for ALPHA target support
00084  * swapping supported disabled until it can be tested further
00085  *
00086  * Revision 1.3  1997/01/06  15:58:53  taustin
00087  * comments updated
00088  *
00089  * Revision 1.1  1996/12/05  18:50:23  taustin
00090  * Initial revision
00091  *
00092  *
00093  */
00094 
00095 #ifndef ENDIAN_H
00096 #define ENDIAN_H
00097 
00098 /* data swapping functions, from big/little to little/big endian format */
00099 #define SWAP_HALF(X)                                                    \
00100   (((((half_t)(X)) & 0xff) << 8) | ((((half_t)(X)) & 0xff00) >> 8))
00101 #define SWAP_WORD(X)    (((word_t)(X) << 24) |                          \
00102                          (((word_t)(X) << 8)  & 0x00ff0000) |           \
00103                          (((word_t)(X) >> 8)  & 0x0000ff00) |           \
00104                          (((word_t)(X) >> 24) & 0x000000ff))
00105 #define SWAP_QWORD(X)   (((qword_t)(X) << 56) |                         \
00106                          (((qword_t)(X) << 40) & ULL(0x00ff000000000000)) |\
00107                          (((qword_t)(X) << 24) & ULL(0x0000ff0000000000)) |\
00108                          (((qword_t)(X) << 8)  & ULL(0x000000ff00000000)) |\
00109                          (((qword_t)(X) >> 8)  & ULL(0x00000000ff000000)) |\
00110                          (((qword_t)(X) >> 24) & ULL(0x0000000000ff0000)) |\
00111                          (((qword_t)(X) >> 40) & ULL(0x000000000000ff00)) |\
00112                          (((qword_t)(X) >> 56) & ULL(0x00000000000000ff)))
00113 
00114 /* recognized endian formats */
00115 enum endian_t { endian_big, endian_little, endian_unknown};
00116 /* probe host (simulator) byte endian format */
00117 enum endian_t
00118 endian_host_byte_order(void);
00119 
00120 /* probe host (simulator) double word endian format */
00121 enum endian_t
00122 endian_host_word_order(void);
00123 
00124 #ifndef HOST_ONLY
00125 
00126 /* probe target (simulated program) byte endian format, only
00127    valid after program has been loaded */
00128 enum endian_t
00129 endian_target_byte_order(void);
00130 
00131 /* probe target (simulated program) double word endian format,
00132    only valid after program has been loaded */
00133 enum endian_t
00134 endian_target_word_order(void);
00135 
00136 #endif /* HOST_ONLY */
00137 
00138 #endif /* ENDIAN_H */

Generated on Fri Oct 22 2010 11:02:18 for SST by  doxygen 1.7.1