Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

gm.h

Go to the documentation of this file.
00001 /******************************************************************-*-c-*-
00002  * Myricom GM networking software and documentation                      *
00003  * Copyright (c) 1999 by Myricom, Inc.                                   *
00004  * All rights reserved.  See the file `COPYING' for copyright notice.    *
00005  *************************************************************************/
00006 
00014 #ifndef _gm_h_
00015 #define _gm_h_
00016 
00017 /*# This file includes the minimum amount needed to support the GM API.
00018    It should not include any other header file or depend on any macro
00019    definitions that are not automatically set by the compiler. */
00020 
00021 /************************************************************************
00022  * Begin Prologue
00023  ************************************************************************/
00024 
00025 #ifdef  __cplusplus
00026 extern "C"
00027 {
00028 #if 0
00029 }                               /* indent hack */
00030 #endif
00031 #endif
00032 
00033 /****************
00034  * Compiler command line switch defaults.
00035  ****************/
00036 
00037 #ifndef GM_BUILDING_GM
00038 #define GM_BUILDING_GM 0
00039 #define GM_BUILDING_FIRMWARE 0
00040 #define GM_BUILDING_INTERNALS 0
00041 #endif
00042 
00043 #ifndef GM_KERNEL
00044 #define GM_KERNEL 0
00045 #endif
00046 
00047 /****************
00048  * Includes
00049  ****************/
00050 
00051 #if GM_BUILDING_FIRMWARE
00052 #include "gm_config.h"
00053 #else
00054 /* There must be no inludes for user (a.k.a.: "GM client") compilations. */
00055 #endif
00056 
00057 /************************************************************************
00058  * End Prologue
00059  ************************************************************************/
00060 
00064 #define GM_API_VERSION_1_0 0x100
00065 
00066 #define GM_API_VERSION_1_1 0x101
00067 
00068 #define GM_API_VERSION_1_2 0x102
00069 
00070 #define GM_API_VERSION_1_3 0x103
00071 
00072 #define GM_API_VERSION_1_4 0x104
00073 
00074 #define GM_API_VERSION_1_5 0x105
00075 
00076 #define GM_API_VERSION_1_6 0x106
00077 
00078 #define GM_API_VERSION_2_0 0x200
00079 
00080 #define GM_API_VERSION_2_0_6 0x20006
00081 
00084 #ifndef GM_API_VERSION
00085 #define GM_API_VERSION GM_API_VERSION_2_0_6
00086 #endif
00087 
00088 /* Check that the user has selected an API version compatible with this
00089    header file. */
00090 
00091 #if GM_API_VERSION < GM_API_VERSION_1_0
00092 #error GM_API_VERSION is too small.
00093 #elif GM_API_VERSION > GM_API_VERSION_2_0_6
00094 #error GM_API_VERSION is too large.
00095 #endif
00096 
00097 /****************************************************************
00098  * Prevent direct access to these functions in GM intself, so that we
00099  * can check for memory leaks.
00100  ****************************************************************/
00101 
00102 #if GM_BUILDING_GM
00103 #include "gm_debug_malloc.h"
00104 #endif
00105 
00108 /****
00109  * Constants
00110  ****/
00111 
00113 #define GM_MAX_HOST_NAME_LEN 128
00114 
00115 #define GM_MAX_PORT_NAME_LEN 32
00116 
00117 #define GM_NO_SUCH_NODE_ID 0
00118 
00119 /************
00120  * Determine CPU based on what compiler is being used.
00121  ************/
00122 
00123 #if defined GM_CPU_alpha
00124 #  define GM_CPU_DEFINED 1
00125 #elif defined GM_CPU_lanai
00126 #  define GM_CPU_DEFINED 1
00127 #elif defined GM_CPU_mips
00128 #  define GM_CPU_DEFINED 1
00129 #elif defined GM_CPU_powerpc
00130 #  define GM_CPU_DEFINED 1
00131 #elif defined GM_CPU_powerpc64
00132 #  define GM_CPU_DEFINED 1
00133 #elif defined GM_CPU_sparc
00134 #  define GM_CPU_DEFINED 1
00135 #elif defined GM_CPU_sparc64
00136 #  define GM_CPU_DEFINED 1
00137 #elif defined GM_CPU_x86
00138 #  define GM_CPU_DEFINED 1
00139 #elif defined GM_CPU_x86_64
00140 #  define GM_CPU_DEFINED 1
00141 #elif defined GM_CPU_hppa
00142 #  define GM_CPU_DEFINED 1
00143 #elif defined GM_CPU_ia64
00144 #  define GM_CPU_DEFINED 1
00145 #else
00146 #  define GM_CPU_DEFINED 0
00147 #endif
00148 
00149 #if !GM_CPU_DEFINED
00150 #  if defined _MSC_VER          /* Microsoft compiler */
00151 #    if defined _M_IX86
00152 #      define GM_CPU_x86 1
00153 #    elif defined _M_IA64
00154 #      define GM_CPU_ia64 1
00155 #    elif defined _M_AMD64
00156 #      define GM_CPU_x86_64 1
00157 #    elif defined _M_ALPHA
00158 #      define GM_CPU_alpha 1
00159 #    else
00160 #      error Could not determine CPU type.  You need to modify gm.h.
00161 #    endif
00162 #  elif defined __APPLE_CC__    /* Apple OSX compiler defines __GNUC__ */
00163 #    if defined __ppc__         /* but doesn't support #cpu syntax     */
00164 #      define GM_CPU_powerpc 1
00165 #    elif define __i386__
00166 #      define GM_CPU_x86 1
00167 #    else
00168 #      error Could not determine CPU type.  You need to modify gm.h.
00169 #    endif
00170 #  elif defined mips
00171 #    define GM_CPU_mips 1
00172 #  elif defined(__GNUC__)
00173 #    if #cpu(alpha)
00174 #      define GM_CPU_alpha 1
00175 #    elif #cpu(hppa)
00176 #      define GM_CPU_hppa 1
00177 #    elif defined lanai
00178 #      define GM_CPU_lanai 1
00179 #    elif defined lanai3
00180 #      define GM_CPU_lanai 1
00181 #    elif defined lanai7
00182 #      define GM_CPU_lanai 1
00183 #    elif defined(powerpc64)
00184 #      define GM_CPU_powerpc64 1
00185 #    elif defined(__powerpc64__)
00186 #      define GM_CPU_powerpc64 1
00187 #    elif defined(powerpc)
00188 #      define GM_CPU_powerpc 1
00189 #    elif defined(_POWER)
00190 #      define GM_CPU_powerpc 1
00191 #    elif defined(_IBMR2)
00192 #      define GM_CPU_powerpc 1
00193 #    elif #cpu(ia64)
00194 #      define GM_CPU_ia64 1
00195 #    elif #cpu(sparc64)
00196 #      define GM_CPU_sparc64 1
00197 #    elif defined sparc
00198 #      define GM_CPU_sparc 1
00199 #    elif defined i386
00200 #      define GM_CPU_x86 1
00201 #    elif #cpu(x86_64)
00202 #      define GM_CPU_x86_64 1
00203 #    elif defined(CPU)   /* This is how vxWorks defines their CPUs */
00204 #      if (CPU==PPC603)
00205 #        define GM_CPU_powerpc 1
00206 #      elif (CPU==PPC604)
00207 #        define GM_CPU_powerpc 1
00208 #      elif (CPU==PPC405)
00209 #        define GM_CPU_powerpc 1
00210 #      else
00211 #        error Could not determine CPU type.  If this is VxWorks, you will need to modify gm.h to add your cpu type.
00212 #      endif
00213 #    else
00214 #      error Could not determine CPU type.  You need to modify gm.h.
00215 #    endif
00216 #  elif (defined (_POWER) && defined(_AIX))
00217 #      define GM_CPU_powerpc 1
00218 #  elif (defined __powerpc__)
00219 #      define GM_CPU_powerpc 1
00220 #  elif (defined (__DECC) || defined (__DECCXX)) && defined(__alpha)
00221 #      define GM_CPU_alpha 1
00222 #  elif (defined (__SUNPRO_C) || defined(__SUNPRO_CC)) && (defined(sparc64) || defined(__sparcv9))
00223 #      define GM_CPU_sparc64 1
00224 #  elif (defined (__SUNPRO_C) || defined(__SUNPRO_CC)) && defined(sparc)
00225 #      define GM_CPU_sparc 1
00226 #  elif (defined (__SUNPRO_C) || defined(__SUNPRO_CC)) && defined i386
00227 #      define GM_CPU_x86 1
00228 #  elif defined __PGI 
00229 #    if defined  __x86_64__
00230 #      define GM_CPU_x86_64 1
00231 #    else       
00232 #      define GM_CPU_x86 1
00233 #    endif
00234 #  elif defined __linux__       /* Portland Group Compiler */
00235 #    if defined __i386__
00236 #      define GM_CPU_x86 1
00237 #    elif defined __ia64__
00238 #      define GM_CPU_ia64 1
00239 #    else
00240 #      error Could not determine CPU type.  You need to modify gm.h.
00241 #    endif
00242 #  elif defined(__hppa) || defined(_PA_RISC1_1)
00243 #      define GM_CPU_hppa 1
00244 #  else
00245 #    error Could not determine CPU type.  You need to modify gm.h.
00246 #  endif
00247 #  undef GM_CPU_DEFINED
00248 #  define GM_CPU_DEFINED 1
00249 #endif
00250 
00254 #ifndef GM_CPU_alpha
00255 #define GM_CPU_alpha 0
00256 #endif
00257 #ifndef GM_CPU_ia64
00258 #define GM_CPU_ia64 0
00259 #endif
00260 #ifndef GM_CPU_hppa
00261 #define GM_CPU_hppa 0
00262 #endif
00263 #ifndef GM_CPU_lanai
00264 #define GM_CPU_lanai 0
00265 #endif
00266 #ifndef GM_CPU_mips
00267 #define GM_CPU_mips 0
00268 #endif
00269 #ifndef GM_CPU_powerpc
00270 #define GM_CPU_powerpc 0
00271 #endif
00272 #ifndef GM_CPU_powerpc64
00273 #define GM_CPU_powerpc64 0
00274 #endif
00275 #ifndef GM_CPU_sparc
00276 #define GM_CPU_sparc 0
00277 #endif
00278 #ifndef GM_CPU_sparc64
00279 #define GM_CPU_sparc64 0
00280 #endif
00281 #ifndef GM_CPU_x86
00282 #define GM_CPU_x86 0
00283 #endif
00284 #ifndef GM_CPU_x86_64
00285 #define GM_CPU_x86_64 0
00286 #endif
00287 
00288 /************
00289  * Enable inlining if and only if we know it won't crash the compiler.
00290  ************/
00291 
00292 
00293 #ifndef gm_inline
00294 #  if defined _MSC_VER
00295 #    define gm_inline __inline
00296 #  elif defined __GNUC__
00297 #    define gm_inline __inline__
00298 #  elif GM_CPU_mips
00299 #    define gm_inline __inline
00300 #    define inline __inline
00301 #  elif defined __DECC
00302 #    define gm_inline __inline
00303 #  elif defined __DECCXX
00304 #    define gm_inline
00305 #  else
00306 #    define gm_inline
00307 #  endif
00308 #endif
00309 
00310 /************
00311  * Define sized types
00312  ************/
00313 
00314 /* gm_s64_t   64-bit signed   integer
00315    gm_s32_t   32-bit signed   integer
00316    gm_s16_t   16-bit signed   integer
00317    gm_s8_t     8-bit signed   integer
00318    gm_u64_t   64-bit unsigned integer
00319    gm_u32_t   32-bit unsigned integer
00320    gm_u16_t   16-bit unsigned integer
00321    gm_u8_t     8-bit unsigned integer */
00322 
00323 #if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__DECC) || defined(__DECCXX) || defined (__IBMC__) || defined (__IBMCPP__)
00324 #if ((GM_CPU_sparc64 || GM_CPU_powerpc64) && defined(__linux__)) && !GM_BUILDING_FIRMWARE
00325 #if GM_KERNEL
00326 typedef signed long gm_s64_t;
00327 typedef unsigned long gm_u64_t;
00328 #else
00329 typedef signed long long gm_s64_t;
00330 typedef unsigned long long gm_u64_t;
00331 #endif /* GM_KERNEL */
00332 #else
00333 #if (GM_CPU_alpha || GM_CPU_sparc64) && !GM_BUILDING_FIRMWARE
00334 typedef signed long gm_s64_t;
00335 typedef unsigned long gm_u64_t;
00336 #else
00337 typedef signed long long gm_s64_t;
00338 typedef unsigned long long gm_u64_t;
00339 #endif
00340 #endif
00341 
00343 typedef signed int gm_s32_t;
00345 typedef signed short gm_s16_t;
00347 typedef signed char gm_s8_t;
00349 typedef unsigned int gm_u32_t;
00351 typedef unsigned short gm_u16_t;
00353 typedef unsigned char gm_u8_t;
00354 #elif defined _MSC_VER
00355 typedef signed __int64 gm_s64_t;
00356 typedef unsigned __int64 gm_u64_t;
00357 typedef signed __int32 gm_s32_t;
00358 typedef signed __int16 gm_s16_t;
00359 typedef signed __int8 gm_s8_t;
00360 typedef unsigned __int32 gm_u32_t;
00361 typedef unsigned __int16 gm_u16_t;
00362 typedef unsigned __int8 gm_u8_t;
00363 #elif GM_CPU_mips               /* see /usr/include/sgidefs.h */
00364 #if (_MIPS_SZLONG == 64)
00365 typedef long gm_s64_t;
00366 typedef unsigned long gm_u64_t;
00367 #elif defined(_LONGLONG)
00368 typedef long long gm_s64_t;
00369 typedef unsigned long long gm_u64_t;
00370 #else
00371 /* __long_long is a hidden builtin, ansi-compliant 64-bit type.  It
00372    should be used only here; henceforward, the gm_ types should be used. */
00373 typedef __long_long gm_s64_t;
00374 typedef unsigned __long_long gm_u64_t;
00375 #endif
00376 typedef int gm_s32_t;
00377 typedef signed short gm_s16_t;
00378 typedef signed char gm_s8_t;
00379 typedef unsigned gm_u32_t;
00380 typedef unsigned short gm_u16_t;
00381 typedef unsigned char gm_u8_t;
00382 #elif defined __PGI || defined(i386) || defined(__i386)         /* Need cpu macros? */
00383 typedef signed long long gm_s64_t;
00384 typedef signed int gm_s32_t;
00385 typedef signed short gm_s16_t;
00386 typedef signed char gm_s8_t;
00387 typedef unsigned long long gm_u64_t;
00388 typedef unsigned int gm_u32_t;
00389 typedef unsigned short gm_u16_t;
00390 typedef unsigned char gm_u8_t;
00391 #elif (defined (__SUNPRO_C) || defined (__SUNPRO_CC)) && (defined(sparc64) || defined(__sparcv9))
00392 typedef signed long gm_s64_t;
00393 typedef signed int gm_s32_t;
00394 typedef signed short gm_s16_t;
00395 typedef signed char gm_s8_t;
00396 typedef unsigned long gm_u64_t;
00397 typedef unsigned int gm_u32_t;
00398 typedef unsigned short gm_u16_t;
00399 typedef unsigned char gm_u8_t;
00400 #elif (defined (__SUNPRO_C) || defined (__SUNPRO_CC)) && defined(__sparc)
00401 typedef signed long long gm_s64_t;
00402 typedef signed int gm_s32_t;
00403 typedef signed short gm_s16_t;
00404 typedef signed char gm_s8_t;
00405 typedef unsigned long long gm_u64_t;
00406 typedef unsigned int gm_u32_t;
00407 typedef unsigned short gm_u16_t;
00408 typedef unsigned char gm_u8_t;
00409 #elif (defined (__SUNPRO_C) || defined (__SUNPRO_CC)) && defined i386
00410 typedef signed long long gm_s64_t;
00411 typedef signed int gm_s32_t;
00412 typedef signed short gm_s16_t;
00413 typedef signed char gm_s8_t;
00414 typedef unsigned long long gm_u64_t;
00415 typedef unsigned int gm_u32_t;
00416 typedef unsigned short gm_u16_t;
00417 typedef unsigned char gm_u8_t;
00418 #elif defined(__hpux)
00419 typedef signed long gm_s64_t;
00420 typedef signed int gm_s32_t;
00421 typedef signed short gm_s16_t;
00422 typedef signed char gm_s8_t;
00423 typedef unsigned long gm_u64_t;
00424 typedef unsigned int gm_u32_t;
00425 typedef unsigned short gm_u16_t;
00426 typedef unsigned char gm_u8_t;
00427 #elif defined(__AIX__) || defined(_AIX)
00428 typedef signed long long gm_s64_t;
00429 typedef signed int gm_s32_t;
00430 typedef signed short gm_s16_t;
00431 typedef signed char gm_s8_t;
00432 typedef unsigned long long gm_u64_t;
00433 typedef unsigned int gm_u32_t;
00434 typedef unsigned short gm_u16_t;
00435 typedef unsigned char gm_u8_t;
00436 #else
00437 #  error Could not define sized types.  You need to modify gm.h.
00438 #endif
00439 
00440 /************
00441  * LANai-compatible host-side pointer representation
00442  ************/
00443 
00444 /* Define size of host pointers */
00445 
00446 #if GM_BUILDING_FIRMWARE
00447 #  define GM_SIZEOF_VOID_P 4
00448 #else
00449 #  if GM_CPU_sparc64 && defined(__linux__) && !GM_KERNEL
00450 #    define GM_SIZEOF_VOID_P 4
00451 #  elif GM_CPU_sparc64
00452 #    define GM_SIZEOF_VOID_P 8
00453 #  elif GM_CPU_sparc
00454 #    define GM_SIZEOF_VOID_P 4
00455 #  elif GM_CPU_x86
00456 #    define GM_SIZEOF_VOID_P 4
00457 #  elif GM_CPU_x86_64
00458 #    define GM_SIZEOF_VOID_P 8
00459 #  elif GM_CPU_ia64
00460 #    define GM_SIZEOF_VOID_P 8
00461 #  elif GM_CPU_alpha
00462 #    define GM_SIZEOF_VOID_P 8
00463 #  elif GM_CPU_mips
00464 #    ifdef _MIPS_SZPTR
00465 #      define GM_SIZEOF_VOID_P (_MIPS_SZPTR / 8)
00466 #    else
00467 #      error Failed to define _MIPS_SZPTR
00468 #    endif
00469 #  elif GM_CPU_powerpc
00470 #    define GM_SIZEOF_VOID_P 4
00471 #  elif GM_CPU_powerpc64
00472 #    define GM_SIZEOF_VOID_P 8
00473 #  elif GM_CPU_hppa
00474 #    define GM_SIZEOF_VOID_P 8
00475 #  else
00476 #    error Could not determine host pointer size.  You need to modify gm.h.
00477 #  endif
00478 #endif
00479 
00480 /* GM_SIZEOF_UP_T */
00481 
00482 /****************
00483  * GM_SIZEOF_UP_T: GM user pointers
00484  *
00485  * This is a tricky definition.  From the point of view of the GM
00486  * internals (the firmware, libgm, the driver, and certain debug
00487  * programs) all user pointers are the maximum size supported on the
00488  * system, and GM_SIZEOF_UP_T is defined by the build environment.
00489  *
00490  * From the point of view of the GM client application, gm_up_t's are
00491  * the same size as a "void *" in that application by default.
00492  *
00493  * Note that in structure in the GM API, there is a 32-bit pad before
00494  * any 32-bit user pointer to make GM's internal and external layouts
00495  * for these structures be compatible.
00496  ****************/
00497 
00498 #if GM_BUILDING_INTERNALS
00499 
00500 #ifndef GM_SIZEOF_UP_T
00501 #error GM_SIZEOF_UP_T should be defined on the compiler command line
00502 #endif
00503 
00504 #else  /* ndef GM_BUILDING_INTERNALS */
00505 
00506 #define GM_SIZEOF_UP_T GM_SIZEOF_VOID_P
00507 
00508 #endif /* ndef GM_BUILDING_INTERNALS */
00509 
00519 /* Define host pointer types
00520 
00521    gm_up_t   unsigned int the size of a user pointer */
00522 
00523 #if GM_SIZEOF_UP_T == 4
00524 typedef gm_u32_t gm_up_t;
00525 #elif GM_SIZEOF_UP_T == 8
00526 typedef gm_u64_t gm_up_t;
00527 #else
00528 #  error Host pointer size is not supported.
00529 #endif
00530 
00531 typedef gm_u64_t gm_remote_ptr_t;       /* assume remote pointers are large */
00532 
00533 /****************************************************************
00534  * Endianess
00535  ****************************************************************/
00536 
00537 /* Determine endianness */
00538 
00539 #if GM_CPU_alpha
00540 #  define GM_CPU_BIGENDIAN 0
00541 #elif GM_CPU_lanai
00542 #  define GM_CPU_BIGENDIAN 1
00543 #elif GM_CPU_mips
00544 #  define GM_CPU_BIGENDIAN 1
00545 #elif GM_CPU_powerpc
00546 #  define GM_CPU_BIGENDIAN 1
00547 #elif GM_CPU_powerpc64
00548 #  define GM_CPU_BIGENDIAN 1
00549 #elif GM_CPU_sparc
00550 #  define GM_CPU_BIGENDIAN 1
00551 #elif GM_CPU_sparc64
00552 #  define GM_CPU_BIGENDIAN 1
00553 #elif GM_CPU_hppa
00554 #  define GM_CPU_BIGENDIAN 1
00555 #elif GM_CPU_x86
00556 #  define GM_CPU_BIGENDIAN 0
00557 #elif GM_CPU_x86_64
00558 #  define GM_CPU_BIGENDIAN 0
00559 #elif GM_CPU_ia64
00560 #  define GM_CPU_BIGENDIAN 0
00561 #else
00562 #  error Could not determine endianness.  You need to modify gm.h.
00563 #endif
00564 
00565 /****************
00566  * Network-order types, strongly typed on the host
00567  ****************/
00568 
00569 /* The default behaviour is to turn on strong typing, except when
00570    using 64-bit Solaris compilers, which will pad the strong types,
00571    breaking this feature.
00572    loic: SUN compiler generates call to .stretx for functions returning
00573    structures, that leads to undefined symbols for kernel code,
00574    so I disabled strong typing even for 32bit with SUN compilers */
00575 
00576 #ifndef GM_STRONG_TYPES
00577 #if (defined __SUNPRO_C || defined __SUNPRO_CC) && (defined __sparc || defined __sparcv9)
00578 #define GM_STRONG_TYPES 0
00579 #else
00580 #define GM_STRONG_TYPES 1
00581 #endif
00582 #endif /* ndef GM_STRONG_TYPES */
00583 
00584 /* Prevent usage of strong types on 64-bit Solaris machines.  These are
00585    big-endian anyway, so no one should need it there. */
00586 
00587 #if GM_STRONG_TYPES && (defined __SUNPRO_C || defined __SUNPRO_CC) && (defined __sparc || defined __sparcv9)
00588 #error GM_STRONG_TYPES is incompatible with Solaris compilers
00589 #endif
00590 
00591 #if !GM_BUILDING_FIRMWARE && GM_STRONG_TYPES
00592 
00596 typedef struct
00597 {
00598   gm_remote_ptr_t n;
00599 }
00600 gm_remote_ptr_n_t;
00602 typedef struct
00603 {
00604   gm_s16_t n;
00605 }
00606 gm_s16_n_t;
00608 typedef struct
00609 {
00610   gm_s32_t n;
00611 }
00612 gm_s32_n_t;
00614 typedef struct
00615 {
00616   gm_s64_t n;
00617 }
00618 gm_s64_n_t;
00620 typedef struct
00621 {
00622   gm_s8_t n;
00623 }
00624 gm_s8_n_t;
00626 typedef struct
00627 {
00628   gm_u16_t n;
00629 }
00630 gm_u16_n_t;
00632 typedef struct
00633 {
00634   gm_u32_t n;
00635 }
00636 gm_u32_n_t;
00638 typedef struct
00639 {
00640   gm_u64_t n;
00641 }
00642 gm_u64_n_t;
00644 typedef struct
00645 {
00646   gm_u8_t n;
00647 }
00648 gm_u8_n_t;
00653 typedef struct
00654 {
00655   gm_up_t n;
00656 }
00657 gm_up_n_t;
00658 typedef gm_up_n_t gm_up_n_up_n_t;
00659 #define GM_N(x) ((x).n)
00660 
00661 #else /* GM_BUILDING_FIRMWARE || !GM_STRONG_TYPES */
00662 
00663 typedef gm_remote_ptr_t gm_remote_ptr_n_t;
00664 typedef gm_s16_t gm_s16_n_t;
00665 typedef gm_s32_t gm_s32_n_t;
00666 typedef gm_s64_t gm_s64_n_t;
00667 typedef gm_s8_t gm_s8_n_t;
00668 typedef gm_u16_t gm_u16_n_t;
00669 typedef gm_u32_t gm_u32_n_t;
00670 typedef gm_u64_t gm_u64_n_t;
00671 typedef gm_u8_t gm_u8_n_t;
00672 typedef gm_up_t gm_up_n_t;
00673 typedef gm_up_t gm_up_n_up_n_t;
00674 #define GM_N(x) (x)
00675 
00676 #endif /* GM_BUILDING_FIRMWARE || !GM_STRONG_TYPES*/
00677 
00678 /****************************************************************
00679  * Byte order conversion
00680  ****************************************************************/
00681 
00682 /********************************
00683  * Unconditional conversion
00684  ********************************/
00685 
00686 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00687 
00688 /* Define __gm_swap* macros, which always reverse the order of bytes. */
00689 
00690 gm_inline static gm_u8_t
00691 __gm_swap_u8 (gm_u8_t x)
00692 {
00693   return x;
00694 }
00695 
00696 gm_inline static gm_u16_t
00697 __gm_swap_u16 (gm_u16_t x)
00698 {
00699   return (((x >> 8) & 0xff) | ((x & 0xff) << 8));
00700 }
00701 
00702 /* Architecture-independent C implementation. */
00703 
00704 gm_inline static gm_u32_t
00705 __gm_swap_u32_C (gm_u32_t x)
00706 {
00707   return (((x >> 24) & 0xff)
00708           | ((x >> 8) & 0xff00) | ((x & 0xff00) << 8) | ((x & 0xff) << 24));
00709 }
00710 
00711 /* Architecture-specific assembly implementations */
00712 
00713 gm_inline static gm_u32_t
00714 __gm_swap_u32_asm (gm_u32_t x)
00715 {
00716 #if defined __GNUC__ && GM_CPU_x86 && defined __OPTIMIZE__ && __OPTIMIZE__ && 0
00717 __asm__ ("bswap %0": "=r" (x):"0" (x));
00718   return x;
00719 #else
00720   return __gm_swap_u32_C (x);
00721 #endif
00722 }
00723 
00724 gm_inline static gm_u32_t
00725 __gm_swap_u32 (gm_u32_t x)
00726 {
00727 #ifdef __GNUC__
00728   /* Use C implementation for constants to allow compile-time swapping.
00729      Otherwise, use fast assembly implementation. */
00730   return __builtin_constant_p (x) ? __gm_swap_u32_C (x) :
00731     __gm_swap_u32_asm (x);
00732 #else
00733   return __gm_swap_u32_C (x);
00734 #endif
00735 }
00736 
00737 /* These unconditional conversion macros are used by the conditional
00738    conversion macros below */
00739 
00740 gm_inline static gm_u64_t
00741 __gm_swap_u64 (gm_u64_t x)
00742 {
00743   volatile union
00744   {
00745     gm_u64_t u64;
00746     gm_u32_t u32[2];
00747   }
00748   ret, old;
00749 
00750   old.u64 = x;
00751   ret.u32[0] = __gm_swap_u32 (old.u32[1]);
00752   ret.u32[1] = __gm_swap_u32 (old.u32[0]);
00753   return ret.u64;
00754 }
00755 
00756 /****************************************************************
00757  * Strongly typed conversion
00758  ****************************************************************/
00759 
00760 /********************************
00761  * Conditional conversion
00762  ********************************/
00763 
00764 #if GM_CPU_BIGENDIAN || GM_BUILDING_FIRMWARE
00765 #define GM_NET_SWAP 0
00766 #else
00767 #define GM_NET_SWAP 1
00768 #endif
00769 
00770 /* Swap using weak typing. */
00771 
00772 #if GM_NET_SWAP
00773 #define __GM_NET_SWAP(type,size,x) \
00774 ((gm##type##size##_t) __gm_swap_u##size ((gm_u##size##_t) (x)))
00775 #else
00776 #define __GM_NET_SWAP(type,size,x) ((gm##type##size##_t) (x))
00777 #endif
00778 
00779 #if GM_NET_SWAP
00780 #define __GM_PCI_SWAP(type,size,x) ((gm##type##size##_t) (x))
00781 #else
00782 #define __GM_PCI_SWAP(type,size,x) \
00783 ((gm##type##size##_t) __gm_swap_u##size ((gm_u##size##_t) (x)))
00784 #endif
00785 
00786 /* These gm_ntoh* macros perform strong type checking, allowing the
00787    compiler to ensure that no network-ordered fields are used by host
00788    code without first being converted to host byte order by these
00789    functions.  The only way to circumvent this strong checking is
00790    using memory copies or complicated casts.  The compiler will catch
00791    simple casts. */
00792 
00793 /****************
00794  * network to host
00795  ****************/
00796 
00797 /* Macro to define gm_ntoh_u8(), etc. */
00798 
00799 #define _GM_NTOH(type, size)                                            \
00800                                                                         \
00801 /* swap using weak typing */                                            \
00802                                                                         \
00803 gm_inline static                                                        \
00804 gm##type##size##_t                                                      \
00805 __gm_ntoh##type##size (gm##type##size##_t x)                            \
00806 {                                                                       \
00807   return __GM_NET_SWAP (type, size, x);                                 \
00808 }                                                                       \
00809                                                                         \
00810 /* swap using strong typing */                                          \
00811                                                                         \
00812 gm_inline static                                                        \
00813 gm##type##size##_t                                                      \
00814 _gm_ntoh##type##size (gm##type##size##_n_t x)                           \
00815 {                                                                       \
00816   return __gm_ntoh##type##size (GM_N (x));                              \
00817 }                                                                       \
00818                                                                         \
00819 struct gm_ignore_the_semicolon
00820 
00821 _GM_NTOH (_u, 8);
00822 _GM_NTOH (_u, 16);
00823 _GM_NTOH (_u, 32);
00824 _GM_NTOH (_u, 64);
00825 
00826 _GM_NTOH (_s, 8);
00827 _GM_NTOH (_s, 16);
00828 _GM_NTOH (_s, 32);
00829 _GM_NTOH (_s, 64);
00830 
00831 /****************
00832  * host to network
00833  ****************/
00834 
00835 /* Macro to define gm_hton_u8(), etc. */
00836 
00837 #define _GM_HTON(type, size)                                            \
00838                                                                         \
00839 /* swap using weak typing */                                            \
00840                                                                         \
00841 gm_inline static                                                        \
00842 gm##type##size##_t                                                      \
00843 __gm_hton##type##size (gm##type##size##_t x)                            \
00844 {                                                                       \
00845   return __GM_NET_SWAP (type, size, x);                                 \
00846 }                                                                       \
00847                                                                         \
00848 /* swap using strong typing */                                          \
00849                                                                         \
00850 gm_inline static                                                        \
00851 gm##type##size##_n_t                                                    \
00852 _gm_hton##type##size (gm##type##size##_t x)                             \
00853 {                                                                       \
00854   gm##type##size##_n_t ret;                                             \
00855                                                                         \
00856   GM_N (ret) = __gm_hton##type##size (x);                               \
00857   return ret;                                                           \
00858 }
00859 
00860 _GM_HTON (_u, 8)
00861 _GM_HTON (_u, 16)
00862 _GM_HTON (_u, 32)
00863 _GM_HTON (_u, 64)
00864 
00865 _GM_HTON (_s, 8)
00866 _GM_HTON (_s, 16)
00867 _GM_HTON (_s, 32)
00868 _GM_HTON (_s, 64)
00869 
00870 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00871 
00872 /********************************
00873  * host/network conversion macros.
00874  ********************************/
00875 
00876 /* These are just like the "^_gm" versions above, but exist to give
00877    etags something to jump to.  The "_gm" versions above are in a macro
00878    to avoid code replication. */
00879 
00880 gm_inline static gm_u64_t
00881 gm_ntoh_u64 (gm_u64_n_t x)
00882 {
00883   return _gm_ntoh_u64 (x);
00884 }
00885 gm_inline static gm_s64_t
00886 gm_ntoh_s64 (gm_s64_n_t x)
00887 {
00888   return _gm_ntoh_s64 (x);
00889 }
00890 gm_inline static gm_u32_t
00891 gm_ntoh_u32 (gm_u32_n_t x)
00892 {
00893   return _gm_ntoh_u32 (x);
00894 }
00895 gm_inline static gm_s32_t
00896 gm_ntoh_s32 (gm_s32_n_t x)
00897 {
00898   return _gm_ntoh_s32 (x);
00899 }
00900 gm_inline static gm_u16_t
00901 gm_ntoh_u16 (gm_u16_n_t x)
00902 {
00903   return _gm_ntoh_u16 (x);
00904 }
00905 gm_inline static gm_s16_t
00906 gm_ntoh_s16 (gm_s16_n_t x)
00907 {
00908   return _gm_ntoh_s16 (x);
00909 }
00910 gm_inline static gm_u8_t
00911 gm_ntoh_u8 (gm_u8_n_t x)
00912 {
00913   return _gm_ntoh_u8 (x);
00914 }
00915 gm_inline static gm_s8_t
00916 gm_ntoh_s8 (gm_s8_n_t x)
00917 {
00918   return _gm_ntoh_s8 (x);
00919 }
00920 
00921 gm_inline static gm_u64_n_t
00922 gm_hton_u64 (gm_u64_t s)
00923 {
00924   return _gm_hton_u64 (s);
00925 }
00926 gm_inline static gm_s64_n_t
00927 gm_hton_s64 (gm_s64_t s)
00928 {
00929   return _gm_hton_s64 (s);
00930 }
00931 gm_inline static gm_u32_n_t
00932 gm_hton_u32 (gm_u32_t s)
00933 {
00934   return _gm_hton_u32 (s);
00935 }
00936 gm_inline static gm_s32_n_t
00937 gm_hton_s32 (gm_s32_t s)
00938 {
00939   return _gm_hton_s32 (s);
00940 }
00941 gm_inline static gm_u16_n_t
00942 gm_hton_u16 (gm_u16_t s)
00943 {
00944   return _gm_hton_u16 (s);
00945 }
00946 gm_inline static gm_s16_n_t
00947 gm_hton_s16 (gm_s16_t s)
00948 {
00949   return _gm_hton_s16 (s);
00950 }
00951 gm_inline static gm_u8_n_t
00952 gm_hton_u8 (gm_u8_t c)
00953 {
00954   return _gm_hton_u8 (c);
00955 }
00956 gm_inline static gm_s8_n_t
00957 gm_hton_s8 (gm_s8_t c)
00958 {
00959   return _gm_hton_s8 (c);
00960 }
00961 
00962 /* Macro for accessing words in the little endian PCI config space */
00963 
00964 gm_inline static gm_u32_t
00965 gm_htopci_u32 (gm_u32_t x)
00966 {
00967   return __GM_PCI_SWAP (_u, 32, x);
00968 }
00969 
00970 #ifndef DOXYGEN_SHOULD_SKIP_THIS 
00971 
00972 #if !GM_BUILDING_FIRMWARE
00973 gm_inline static void *
00974 gm_ntohp (gm_up_n_t x)
00975 {
00976   /* Odd syntax here to placate "icc -Wall" (Intel cc) */
00977 #if GM_SIZEOF_UP_T == 8
00978   return (void *) ((char *) 0 + __gm_ntoh_u64 (GM_N (x)));
00979 #elif GM_SIZEOF_UP_T == 4
00980   return (void *) ((char *) 0 + __gm_ntoh_u32 (GM_N (x)));
00981 #endif
00982 }
00983 #endif
00984 
00985 /****************
00986  * backwards compatibility
00987  ****************/
00988 
00998 #if !GM_BUILDING_GM
00999 
01000 /* These aliases are for client use only */
01001 
01002 gm_inline static gm_u8_t
01003 gm_ntohc (gm_u8_n_t x)
01004 {
01005   return gm_ntoh_u8 (x);
01006 }
01007 gm_inline static gm_u16_t
01008 gm_ntohs (gm_u16_n_t x)
01009 {
01010   return gm_ntoh_u16 (x);
01011 }
01012 gm_inline static gm_u32_t
01013 gm_ntohl (gm_u32_n_t x)
01014 {
01015   return gm_ntoh_u32 (x);
01016 }
01017 gm_inline static gm_u64_t
01018 gm_ntohll (gm_u64_n_t x)
01019 {
01020   return gm_ntoh_u64 (x);
01021 }
01022 
01023 gm_inline static gm_u8_n_t
01024 gm_htonc (gm_u8_t x)
01025 {
01026   return gm_hton_u8 (x);
01027 }
01028 gm_inline static gm_u16_n_t
01029 gm_htons (gm_u16_t x)
01030 {
01031   return gm_hton_u16 (x);
01032 }
01033 gm_inline static gm_u32_n_t
01034 gm_htonl (gm_u32_t x)
01035 {
01036   return gm_hton_u32 (x);
01037 }
01038 gm_inline static gm_u64_n_t
01039 gm_htonll (gm_u64_t x)
01040 {
01041   return gm_hton_u64 (x);
01042 }
01043 
01044 #define gm_assert_p(a) gm_assert (a)
01045 
01046 #endif /* !GM_BUILDING_GM */
01047 
01048 /************
01049  * GM_ENTRY_POINT definition
01050  ************/
01051 
01052 #ifndef GM_ENTRY_POINT          /* need to override in NT4 make-os.in */
01053 
01054 #if defined _MSC_VER            /* microsoft compiler */
01055 #  if GM_KERNEL
01056 #    define GM_ENTRY_POINT
01057 #  elif GM_BUILDING_GM_LIB
01058 #    define GM_ENTRY_POINT __declspec (dllexport)
01059 #  else
01060 #    define GM_ENTRY_POINT __declspec (dllimport)
01061 #  endif
01062 #else
01063 #  define GM_ENTRY_POINT
01064 #endif
01065 
01066 #endif /* ndef GM_ENTRY_POINT */
01067 
01068 /* Debugging */
01069 
01070 #ifndef GM_DEBUG
01071 #  if !GM_BUILDING_GM
01072 #    define GM_DEBUG 0
01073 #  else  /* GM_BUILDING_GM */
01074 #    error GM_DEBUG must be defined for internal GM builds.
01075 #  endif /* GM_BUILDING_GM */
01076 #endif /* !GM_DEBUG */
01077 
01078 /* A macro like "gm_assert()", only causing an error at compile-time
01079    rather than run time.  The expression A must be a constant
01080    expression.  */
01081 
01082 #if !defined __GNUC__ || defined __STRICT_ANSI__
01083 #define __GM_COMPILE_TIME_ASSERT(a)
01084 #else
01085 #define __GM_COMPILE_TIME_ASSERT(a) do {                                \
01086   char (*__GM_COMPILE_TIME_ASSERT_var)[(a) ? 1 : -1] = 0;               \
01087   (void) __GM_COMPILE_TIME_ASSERT_var; /* prevent unused var warning */ \
01088 } while (0)
01089 #endif
01090 
01091 /****************
01092  * gm_always_assert() and gm_assert()
01093  ****************/
01094 
01095 /* Macro for determining if X is a constant that can be evaluated at
01096    compile time.  This macro is used by gm_always_assert*() to perform as many
01097    compile-time checks as possible. */
01098 
01099 #if defined __GNUC__ && !defined __STRICT_ANSI__
01100 #define __gm_builtin_constant_p(x) __builtin_constant_p (x)
01101 #else
01102 #define __gm_builtin_constant_p(x) 0
01103 #endif
01104 
01105 /* __gm_check_syntax(): (Undocumented, unsupported.) Allow the
01106    compiler to check syntax, on the expression, but don't actually
01107    execute it. */
01108 
01109 #define __gm_check_syntax(x) do {if (0) (void) (x);} while (0)
01110 
01111 /* gm_assert() Assert iff debugging turned on. */
01112 
01113 #if GM_DEBUG
01114 #define gm_assert(a) _gm_always_assert (a, #a)
01115 #else
01116 #define gm_assert(a) __gm_check_syntax (a)
01117 #endif
01118 
01119 #if GM_BUILDING_FIRMWARE && 0
01120 #define __GM_ASSERTION_FAILED(txt, line, file) do {                     \
01121   _gm_assertion_failed ("", line, file);                                \
01122 } while (0)
01123 #else
01124 #define __GM_ASSERTION_FAILED(txt, line, file) do {                     \
01125   _gm_assertion_failed (txt, line, file);                               \
01126 } while (0)
01127 #endif
01128 
01129 /* Special always assert macro with preexpanded assertion string.
01130    This prevents the preprocessor from expanding the exptression before
01131    converting it to a string. */
01132 
01133 #define _gm_always_assert(a,txt) do {                                   \
01134   __GM_COMPILE_TIME_ASSERT (!__gm_builtin_constant_p (a) || (a));       \
01135   if (!(a))                                                             \
01136     {                                                                   \
01137       __GM_ASSERTION_FAILED (txt, __LINE__, __GM_FILE__);               \
01138     }                                                                   \
01139 } while (0)
01140 
01141 /* gm_always_assert(): Always assert, even if debugging is turned off,
01142    unless we are able to to the check at compile-time. */
01143 
01144 #define gm_always_assert(a) _gm_always_assert (a, #a)
01145 
01146 #define GM_ABORT() __GM_ASSERTION_FAILED ("0", __LINE__, __GM_FILE__)
01147 
01148 /****************
01149  * Compiler warning supression macros
01150  ****************/
01151 
01152 #define GM_PARAMETER_MAY_BE_UNUSED(p) ((void)(p))
01153 #define GM_VAR_MAY_BE_UNUSED(v) ((void)(v))
01154 #define GM_LOOPS_FOREVER() { if (0) break; }
01155 
01156 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01157 
01158 /****************************************************************
01159  * typedefs
01160  ****************************************************************/
01161 
01163 typedef enum gm_status
01164 {
01166   GM_SUCCESS = 0,
01168   GM_FAILURE = 1,
01170   GM_INPUT_BUFFER_TOO_SMALL = 2,
01172   GM_OUTPUT_BUFFER_TOO_SMALL = 3,
01174   GM_TRY_AGAIN = 4,
01176   GM_BUSY = 5,
01178   GM_MEMORY_FAULT = 6,
01180   GM_INTERRUPTED = 7,
01182   GM_INVALID_PARAMETER = 8,
01184   GM_OUT_OF_MEMORY = 9,
01186   GM_INVALID_COMMAND = 10,
01188   GM_PERMISSION_DENIED = 11,
01190   GM_INTERNAL_ERROR = 12,
01192   GM_UNATTACHED = 13,
01194   GM_UNSUPPORTED_DEVICE = 14,
01203   GM_SEND_TIMED_OUT = 15,
01207   GM_SEND_REJECTED = 16,
01210   GM_SEND_TARGET_PORT_CLOSED = 17,
01215   GM_SEND_TARGET_NODE_UNREACHABLE = 18,
01218   GM_SEND_DROPPED = 19,
01220   GM_SEND_PORT_CLOSED = 20,
01222   GM_NODE_ID_NOT_YET_SET = 21,
01224   GM_STILL_SHUTTING_DOWN = 22,
01226   GM_CLONE_BUSY = 23,
01228   GM_NO_SUCH_DEVICE = 24,
01230   GM_ABORTED = 25,
01231 #if GM_API_VERSION >= GM_API_VERSION_1_5
01232 
01233   GM_INCOMPATIBLE_LIB_AND_DRIVER = 26,
01235   GM_UNTRANSLATED_SYSTEM_ERROR = 27,
01237   GM_ACCESS_DENIED = 28,
01238 #endif
01239 #if GM_API_VERSION >= GM_API_VERSION_2_0
01240 
01241   GM_NO_DRIVER_SUPPORT = 29,
01243   GM_PTE_REF_CNT_OVERFLOW = 30,
01245   GM_NOT_SUPPORTED_IN_KERNEL = 31,
01247   GM_NOT_SUPPORTED_ON_ARCH = 32,
01249   GM_NO_MATCH = 33,
01251   GM_USER_ERROR = 34,
01253   GM_TIMED_OUT = 35,
01255   GM_DATA_CORRUPTED = 36,
01257   GM_HARDWARE_FAULT = 37,
01259   GM_SEND_ORPHANED = 38,
01261   GM_MINOR_OVERFLOW = 39,
01263   GM_PAGE_TABLE_FULL = 40,
01265   GM_UC_ERROR = 41,
01267   GM_INVALID_PORT_NUMBER = 42,
01269   GM_DEV_NOT_FOUND = 43,
01271   GM_FIRMWARE_NOT_RUNNING = 44,
01273   GM_YP_NO_MATCH = 45,
01274 #endif
01275   /* If you add error codes, also update libgm/gm_strerror.c. --Glenn */
01276 
01277   GM_NUM_STATUS_CODES           /* may change in value */
01278 #if !GM_BUILDING_GM
01279     /* DEPRECATED */ , GM_NUM_ERROR_CODES = GM_NUM_STATUS_CODES
01280 #endif
01281     /* Do not add new codes here. */
01282 }
01283 gm_status_t;
01284 
01286 enum gm_priority
01287 {
01289   GM_LOW_PRIORITY = 0,
01291   GM_HIGH_PRIORITY = 1,
01293   GM_NUM_PRIORITIES = 2
01294 };
01295 
01296 #ifndef DOXYGEN_SHOULD_SKIP_THIS 
01297 
01298 enum gm_buf_status
01299 {
01300   gm_in_send = 0,
01301   gm_in_recv,
01302   gm_in_app,
01303   gm_invalid_status
01304 };
01305 
01306 struct gm_buf_handle
01307 {
01308   void *addr;
01309   int size;
01310   enum gm_buf_status status;
01311   struct gm_buf_handle *next;
01312 };
01313 
01314 
01315 typedef struct gm_alarm
01316 {
01317   struct gm_alarm *next;
01318   enum
01319   {
01320     GM_ALARM_FREE = 0,
01321     GM_ALARM_SET
01322   }
01323   state;
01324   struct gm_port *port;
01325   void (*callback) (void *context);
01326   void *context;
01327   gm_u64_t deadline;
01328 }
01329 gm_alarm_t;
01330 
01331 /* This is a list of GM API versions supported by this version of GM. */
01332 
01333 enum gm_api_version
01334 {
01335   /* symbolic versions for C code to allow symbolic debugging. */
01336   _GM_API_VERSION_1_0 = GM_API_VERSION_1_0,
01337 #if GM_API_VERSION >= GM_API_VERSION_1_1
01338   _GM_API_VERSION_1_1 = GM_API_VERSION_1_1,
01339 #endif
01340 #if GM_API_VERSION >= GM_API_VERSION_1_2
01341   _GM_API_VERSION_1_2 = GM_API_VERSION_1_2,
01342 #endif
01343 #if GM_API_VERSION >= GM_API_VERSION_1_3
01344   _GM_API_VERSION_1_3 = GM_API_VERSION_1_3,
01345 #endif
01346 #if GM_API_VERSION >= GM_API_VERSION_1_4
01347   _GM_API_VERSION_1_4 = GM_API_VERSION_1_4,
01348 #endif
01349 #if GM_API_VERSION >= GM_API_VERSION_1_5
01350   _GM_API_VERSION_1_5 = GM_API_VERSION_1_5,
01351 #endif
01352 #if GM_API_VERSION >= GM_API_VERSION_1_6
01353   _GM_API_VERSION_1_6 = GM_API_VERSION_1_6,
01354 #endif
01355 #if GM_API_VERSION >= GM_API_VERSION_2_0
01356   _GM_API_VERSION_2_0 = GM_API_VERSION_2_0,
01357 #endif
01358 #if GM_API_VERSION >= GM_API_VERSION_2_0_6
01359   _GM_API_VERSION_2_0_6 = GM_API_VERSION_2_0_6,
01360 #endif
01361   __GM_API_VERSION_IGNORE_COMMA
01362 };
01363 
01364 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01365 
01366 /************************************************************************
01367  * Macros
01368  ************************************************************************/
01369 
01370 /* Determine if N is aligned on an M-byte boundary, where M is a power
01371    of 2 */
01372 
01373 #define __GM_MISALIGNMENT(n,m) ((gm_size_t)(n) & ((gm_size_t)(m) - 1))
01374 #define GM_ALIGNED(n,m) (__GM_MISALIGNMENT(n,m) == 0)
01375 
01376 /* NOTE: all GM alignment requirements will be lifted */
01377 
01379 #define GM_RDMA_GRANULARITY 64
01380 
01381 #define GM_MAX_DMA_GRANULARITY 8
01382 #if GM_RDMA_GRANULARITY % GM_MAX_DMA_GRANULARITY
01383 #  error GM_RDMA_GRANULARITY must be a multiple of GM_MAX_DMA_GRANULARITY
01384 #endif
01385 
01386 #if !GM_BUILDING_FIRMWARE
01387 #define GM_DMA_GRANULARITY GM_MAX_DMA_GRANULARITY
01388 #endif
01389 
01390 #define GM_DMA_ALIGNED(p)       GM_ALIGNED (p, GM_DMA_GRANULARITY)
01391 
01392 /************************************************************************
01393  * Recv event type
01394  ************************************************************************/
01395 
01397 enum gm_recv_event_type
01398 {
01399 #if !GM_BUILDING_FIRMWARE                       /* don't use these in the MCP */
01400 
01401   GM_NO_RECV_EVENT = 0,
01403   GM_SENDS_FAILED_EVENT = 1,
01406   GM_ALARM_EVENT = 2,
01408   GM_SENT_EVENT = 3,
01410   _GM_SLEEP_EVENT = 4,
01412   GM_RAW_RECV_EVENT = 5,
01414   GM_BAD_SEND_DETECTED_EVENT = 6,
01416   GM_SEND_TOKEN_VIOLATION_EVENT = 7,
01418   GM_RECV_TOKEN_VIOLATION_EVENT = 8,
01420   GM_BAD_RECV_TOKEN_EVENT = 9,
01422   GM_ALARM_VIOLATION_EVENT = 10,
01425   GM_RECV_EVENT = 11,
01428   GM_HIGH_RECV_EVENT = 12,
01432   GM_PEER_RECV_EVENT = 13,
01436   GM_HIGH_PEER_RECV_EVENT = 14,
01440   GM_FAST_RECV_EVENT = 15,
01444   GM_FAST_HIGH_RECV_EVENT = 16,
01449   GM_FAST_PEER_RECV_EVENT = 17,
01454   GM_FAST_HIGH_PEER_RECV_EVENT = 18,
01456   GM_REJECTED_SEND_EVENT = 19,
01458   GM_ORPHANED_SEND_EVENT = 20,
01462   /* _GM_PUT_NOTIFICATION_EVENT = 21, */
01463   /* GM_FREE_SEND_TOKEN_EVENT = 22, */
01464   /* GM_FREE_HIGH_SEND_TOKEN_EVENT = 23, */
01466   GM_BAD_RESEND_DETECTED_EVENT = 24,
01468   GM_DROPPED_SEND_EVENT = 25,
01470   GM_BAD_SEND_VMA_EVENT = 26,
01472   GM_BAD_RECV_VMA_EVENT = 27,
01474   _GM_FLUSHED_ALARM_EVENT = 28,
01476   GM_SENT_TOKENS_EVENT = 29,
01478   GM_IGNORE_RECV_EVENT = 30,
01480   GM_ETHERNET_RECV_EVENT = 31,
01481 #endif                          /* GM_BUILDING_FIRMWARE not defined */
01482   /****** Types used to make a new event in the queue. ******/
01483   GM_NEW_NO_RECV_EVENT = 128,
01485   GM_NEW_SENDS_FAILED_EVENT = 129,
01487   GM_NEW_ALARM_EVENT = 130,
01489   GM_NEW_SENT_EVENT = 131,
01491   _GM_NEW_SLEEP_EVENT = 132,
01493   GM_NEW_RAW_RECV_EVENT = 133,
01495   GM_NEW_BAD_SEND_DETECTED_EVENT = 134,
01497   GM_NEW_SEND_TOKEN_VIOLATION_EVENT = 135,
01499   GM_NEW_RECV_TOKEN_VIOLATION_EVENT = 136,
01501   GM_NEW_BAD_RECV_TOKEN_EVENT = 137,
01503   GM_NEW_ALARM_VIOLATION_EVENT = 138,
01505   GM_NEW_RECV_EVENT = 139,
01507   GM_NEW_HIGH_RECV_EVENT = 140,
01509   GM_NEW_PEER_RECV_EVENT = 141,
01511   GM_NEW_HIGH_PEER_RECV_EVENT = 142,
01513   GM_NEW_FAST_RECV_EVENT = 143,
01515   GM_NEW_FAST_HIGH_RECV_EVENT = 144,
01517   GM_NEW_FAST_PEER_RECV_EVENT = 145,
01519   GM_NEW_FAST_HIGH_PEER_RECV_EVENT = 146,
01521   GM_NEW_REJECTED_SEND_EVENT = 147,
01523   GM_NEW_ORPHANED_SEND_EVENT = 148,
01525   _GM_NEW_PUT_NOTIFICATION_EVENT = 149,
01527   GM_NEW_FREE_SEND_TOKEN_EVENT = 150,
01529   GM_NEW_FREE_HIGH_SEND_TOKEN_EVENT = 151,
01531   GM_NEW_BAD_RESEND_DETECTED_EVENT = 152,
01533   GM_NEW_DROPPED_SEND_EVENT = 153,
01535   GM_NEW_BAD_SEND_VMA_EVENT = 154,
01537   GM_NEW_BAD_RECV_VMA_EVENT = 155,
01539   _GM_NEW_FLUSHED_ALARM_EVENT = 156,
01541   GM_NEW_SENT_TOKENS_EVENT = 157,
01543   GM_NEW_IGNORE_RECV_EVENT = 158,
01545   GM_NEW_ETHERNET_RECV_EVENT = 159,
01548   GM_NUM_RECV_EVENT_TYPES
01550 };
01551 
01552 /****************
01553  * recv
01554  ****************/
01555 
01556 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01557 
01558 typedef struct gm_recv
01559 {
01560   /* Pad to GM_RDMA_GRANULARITY bytes */
01561 #if (32 % GM_RDMA_GRANULARITY)
01562   gm_u8_n_t _rdma_padding[GM_RDMA_GRANULARITY - (32 % GM_RDMA_GRANULARITY)];
01563 #endif
01564   /* 8 */
01565 #if GM_SIZEOF_UP_T == 4
01566   gm_u32_n_t message_pad;
01567 #endif
01568   gm_up_n_t message;
01569   /* 8 */
01570 #if GM_SIZEOF_UP_T == 4
01571   gm_u32_n_t buffer_pad;
01572 #endif
01573   gm_up_n_t buffer;
01574   /* 8 */
01575   gm_u32_n_t reserved_after_buffer;
01576   gm_u32_n_t length;
01577   /* 8 */
01578   gm_u16_n_t sender_node_id;
01579   gm_u16_n_t reserved_after_sender_node_id;
01580   gm_u8_n_t tag;
01581   gm_u8_n_t size;
01582   gm_u8_n_t sender_port_id;
01583   gm_u8_n_t type;
01584 }
01585 gm_recv_t;
01586 
01587 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01588 
01589 /****************
01590  * sent token report
01591  ****************/
01592 
01593 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01594 
01595 struct _gm_sent_token_report
01596 {
01597   gm_u8_n_t token;
01598   gm_u8_n_t status;
01599 };
01600 
01601 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01602 
01603 #define GM_MAX_SENT_TOKEN_REPORTS_PER_EVENT ((GM_RDMA_GRANULARITY/2) - 1)
01604 
01605 /****************
01606  * tokens sent
01607  ****************/
01608 
01609 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01610 
01611 typedef struct gm_tokens_sent
01612 {
01613   struct _gm_sent_token_report report[GM_MAX_SENT_TOKEN_REPORTS_PER_EVENT];
01614   gm_u8_n_t reserved_before_type;
01615   gm_u8_n_t type;
01616 }
01617 gm_tokens_sent_t;
01618 
01619 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01620 
01621 /****************
01622  * sent
01623  ****************/
01624 
01625 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01626 
01627 #define GM_TOKENS_SENT_EVENT__FIRST (ts) ((gm_u8_t *) (ts + 1) - 2)
01628 
01629 typedef struct gm_sent
01630 {
01631   /* Pad to GM_RDMA_GRANULARITY bytes */
01632 #if (32 % GM_RDMA_GRANULARITY)
01633   gm_u8_n_t _rdma_padding[GM_RDMA_GRANULARITY - (32 % GM_RDMA_GRANULARITY)];
01634 #endif
01635   /* Pad to 32 bytes */
01636   gm_u8_n_t _reserved[16];
01637 #if GM_SIZEOF_UP_T == 4
01638   gm_u8_n_t _reserved_before_message_list[4];
01639 #endif
01640   gm_up_n_up_n_t message_list;
01641   gm_u8_n_t _reserved_after_message_list[8 - 1];
01642   gm_u8_n_t type;
01643 }
01644 gm_sent_t;
01645 
01646 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01647 
01648 /****************
01649  * failed send
01650  ****************/
01651 
01652 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01653 
01654                                 /* Struct of GM_RDMA_GRANULARITY for
01655                                    reporting rejected sends. */
01656 typedef struct gm_failed_send_event
01657 {
01658   /* Pad to GM_RDMA_GRANULARITY bytes */
01659 #if (32 % GM_RDMA_GRANULARITY)
01660   gm_u8_n_t _rdma_padding[GM_RDMA_GRANULARITY - (32 % GM_RDMA_GRANULARITY)];
01661 #endif
01662   /* Pad to 32 bytes */
01663   gm_u8_n_t _reserved[16];
01664   /* 8 */
01665 #if GM_SIZEOF_UP_T == 4
01666   gm_u32_n_t message_pad;
01667 #endif
01668   gm_up_n_t message;
01669   /* 8 */
01670   gm_u32_n_t reserved_after_message;
01671   gm_u16_n_t target_node_id;
01672   gm_u8_n_t target_subport_id;
01673   gm_u8_n_t type;
01674 }
01675 gm_failed_send_event_t;
01676 
01677 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 
01678 
01679 /****************
01680  * flushed alarm
01681  ****************/
01682 
01683 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01684 
01685 typedef struct gm_flushed_alarm
01686 {
01687   /* Pad to GM_RDMA_GRANULARITY bytes */
01688 #if (32 % GM_RDMA_GRANULARITY)
01689   gm_u8_n_t _rdma_padding[GM_RDMA_GRANULARITY - (32 % GM_RDMA_GRANULARITY)];
01690 #endif
01691   /* 8 */
01692 #if GM_MAX_DMA_GRANULARITY != 8
01693 #error
01694 #endif
01695   /* Pad to 32 bytes */
01696   gm_u8_n_t _reserved[32 - 8];
01697   /* 8 */
01698   gm_u32_n_t usecs_remaining;
01699   gm_u8_n_t reserved_after_usecs_remaining[3];
01700   gm_u8_n_t type;
01701 }
01702 gm_flushed_alarm_t;
01703 
01704 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 
01705 
01706 /****************
01707  * Ethernet recv
01708  ****************/
01709 
01710 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01711 
01712 typedef struct gm_ethernet_recv
01713 {
01714   /* Pad to GM_RDMA_GRANULARITY bytes */
01715 #if (32 % GM_RDMA_GRANULARITY)
01716   gm_u8_n_t _rdma_padding[GM_RDMA_GRANULARITY - (32 % GM_RDMA_GRANULARITY)];
01717 #endif
01718   /* Pad to 32 bytes */
01719 #if (16 + 2 * GM_SIZEOF_UP_T) % 32
01720   gm_u8_n_t _reserved[32 - (16 + 2 * GM_SIZEOF_UP_T) % 32];
01721 #endif
01722   gm_up_n_t message;
01723   gm_up_n_t buffer;
01724   /* 8 */
01725   gm_u16_n_t ip_checksum;       /* IPv4 partial checksum, or checksum
01726                                    of entire packet; flags tell which */
01727   gm_u16_n_t ip_header_len;     /* future use */
01728   gm_u32_n_t length;
01729   /* 8 */
01730   gm_u16_n_t sender_node_id;
01731   gm_u8_n_t flags;
01732 #define GM_IPV4_PARTIAL_CHECKSUM        0x1     /* checksum is an IPv4
01733                                                    partial checksum */
01734 #define GM_TCP_UDP_HEADER_SPLIT         0x2     /* future use */
01735   gm_u8_n_t reserved_after_flags;
01736   gm_u8_n_t tag;
01737   gm_u8_n_t size;
01738   gm_u8_n_t sender_port_id;
01739   gm_u8_n_t type;
01740 }
01741 gm_ethernet_recv_t;
01742 
01743 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 
01744 
01745 /****************
01746  * recv event
01747  ****************/
01748 
01749 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01750 
01751 typedef union gm_recv_event
01752 {
01753   /* Each of these must be the same size so the TYPE field at the
01754      end of each is aligned. */
01755   gm_tokens_sent_t tokens_sent;
01756   gm_recv_t recv;
01757   gm_sent_t sent;
01758   gm_failed_send_event_t failed_send;
01759   gm_flushed_alarm_t flushed_alarm;
01760   gm_ethernet_recv_t ethernet_recv;
01761 }
01762 gm_recv_event_t;
01763 
01764 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 
01765 
01766 #define GM_RECV_EVENT_TYPE(e) (gm_ntoh_u8 ((e)->recv.type))
01767 
01768 /* GM equivalent of ANSI "offsetof()" macro, since WindowsNT botches
01769    (or used to botch) it somewhere in the DDK header files. */
01770 
01771 #define GM_OFFSETOF(type,field) ((gm_offset_t) &((type *)0)->field)
01772 
01774 struct gm_port;
01776 typedef void (*gm_send_completion_callback_t) (struct gm_port * p,
01777                                                void *context,
01778                                                gm_status_t status);
01779 
01780 /************************************************************************
01781  * Globals (undefined until gm_init() or gm_open() called).
01782  ************************************************************************/
01783 
01784 #if !defined GM_PAGE_LEN
01785 extern GM_ENTRY_POINT unsigned long GM_PAGE_LEN;
01786 #endif
01787 
01788 /****************************************************************
01789  * Data type abstraction typedefs
01790  ****************************************************************/
01791 
01792 #if defined _M_IA64 || defined _M_AMD64 || (GM_CPU_hppa && !GM_BUILDING_FIRMWARE)
01793 typedef gm_u64_t gm_size_t;
01794 typedef gm_s64_t gm_offset_t;
01795 #else
01796 typedef unsigned long gm_size_t;
01797 typedef signed long gm_offset_t;
01798 #endif
01799 
01800 /****************************************************************
01801  * Function prototypes
01802  ****************************************************************/
01803 
01804 GM_ENTRY_POINT void _gm_assertion_failed (const char *, int, const char *);
01805 
01807 GM_ENTRY_POINT void gm_abort (void);
01808 
01810 GM_ENTRY_POINT int gm_alloc_send_token (struct gm_port *p,
01811                                         unsigned int priority);
01814 GM_ENTRY_POINT gm_status_t gm_allow_remote_memory_access (struct gm_port *p);
01815 
01817 GM_ENTRY_POINT void gm_bcopy (const void *from, void *to, gm_size_t len);
01818 
01821 GM_ENTRY_POINT union gm_recv_event *gm_blocking_receive (struct gm_port *p);
01822 
01826 GM_ENTRY_POINT union
01827   gm_recv_event *gm_blocking_receive_no_spin (struct gm_port *p);
01828 
01830 GM_ENTRY_POINT void gm_bzero (void *ptr, gm_size_t len);
01831 
01833 GM_ENTRY_POINT void *gm_calloc (gm_size_t len, gm_size_t cnt);
01834 
01836 struct gm_alarm;
01837 
01839 GM_ENTRY_POINT void gm_cancel_alarm (struct gm_alarm *gm_alarm);
01840 
01842 GM_ENTRY_POINT void gm_close (struct gm_port *p);
01843 
01845 GM_ENTRY_POINT void gm_datagram_send (struct gm_port *p, void *message,
01846                                       unsigned int size, gm_size_t len,
01847                                       unsigned int priority,
01848                                       unsigned int target_node_id,
01849                                       unsigned int target_port_id,
01850                                       gm_send_completion_callback_t callback,
01851                                       void *context);
01852 
01854 GM_ENTRY_POINT void gm_datagram_send_4 (struct gm_port *p, gm_u32_t message,
01855                                         unsigned int size, gm_size_t len,
01856                                         unsigned int priority,
01857                                         unsigned int target_node_id,
01858                                         unsigned int target_port_id,
01859                                         gm_send_completion_callback_t
01860                                         callback, void *context);
01861 
01863 GM_ENTRY_POINT gm_status_t gm_deregister_memory (struct gm_port *p, void *ptr,
01864                                                  gm_size_t length);
01865 
01866 /* Deprecated function. */ 
01867 GM_ENTRY_POINT void gm_directed_send (struct gm_port *p, void *source_buffer,
01868                                       gm_remote_ptr_t target_buffer,
01869                                       gm_size_t len,
01870                                       enum gm_priority priority,
01871                                       unsigned int target_node_id,
01872                                       unsigned int target_port_id);
01873 
01875 GM_ENTRY_POINT void gm_directed_send_with_callback (struct gm_port *p,
01876                                                     void *source_buffer,
01877                                                     gm_remote_ptr_t
01878                                                     target_buffer,
01879                                                     gm_size_t len,
01880                                                     enum gm_priority priority,
01881                                                     unsigned int
01882                                                     target_node_id,
01883                                                     unsigned int
01884                                                     target_port_id,
01885                                                     gm_send_completion_callback_t
01886                                                     callback, void *context);
01887 
01889 GM_ENTRY_POINT void *gm_dma_calloc (struct gm_port *p, gm_size_t count,
01890                                     gm_size_t length);
01891 
01893 GM_ENTRY_POINT void gm_dma_free (struct gm_port *p, void *addr);
01894 
01896 GM_ENTRY_POINT void *gm_dma_malloc (struct gm_port *p, gm_size_t length);
01897 
01899 GM_ENTRY_POINT void gm_flush_alarm (struct gm_port *p);
01900 
01902 GM_ENTRY_POINT void gm_free (void *ptr);
01903 
01905 GM_ENTRY_POINT void gm_free_send_token (struct gm_port *p,
01906                                         unsigned int priority);
01907 
01909 GM_ENTRY_POINT void gm_free_send_tokens (struct gm_port *p,
01910                                          unsigned int priority,
01911                                          unsigned int count);
01912 
01914 GM_ENTRY_POINT gm_status_t gm_get_host_name (struct gm_port *port,
01915                                              char name[GM_MAX_HOST_NAME_LEN]);
01916 
01918 GM_ENTRY_POINT gm_status_t gm_get_node_type (struct gm_port *port,
01919                                              int *node_type);
01920 
01922 GM_ENTRY_POINT gm_status_t gm_get_node_id (struct gm_port *port,
01923                                            unsigned int *n);
01924 
01927 GM_ENTRY_POINT gm_status_t gm_get_unique_board_id (struct gm_port *port,
01928                                                    char unique[6]);
01929 
01932 GM_ENTRY_POINT gm_status_t gm_get_mapper_unique_id (struct gm_port *port,
01933                                                     char unique[6]);
01934 
01936 GM_ENTRY_POINT void gm_hex_dump (const void *ptr, gm_size_t len);
01937 
01941 GM_ENTRY_POINT unsigned int gm_host_name_to_node_id (struct gm_port *port,
01942                                                      char *_host_name);
01943 
01946 GM_ENTRY_POINT void gm_initialize_alarm (struct gm_alarm *my_alarm);
01947 
01950 GM_ENTRY_POINT int gm_isprint (int c);
01951 
01953 GM_ENTRY_POINT void *gm_malloc (gm_size_t len);
01954 
01957 GM_ENTRY_POINT void *gm_page_alloc (void);
01958 
01960 GM_ENTRY_POINT void gm_page_free (void *addr);
01961 
01963 GM_ENTRY_POINT void *gm_alloc_pages (gm_size_t len);
01964 
01966 GM_ENTRY_POINT void gm_free_pages (void *addr, gm_size_t len);
01967 
01970 GM_ENTRY_POINT gm_size_t gm_max_length_for_size (unsigned int size);
01971 
01974 GM_ENTRY_POINT gm_status_t gm_max_node_id (struct gm_port *port,
01975                                            unsigned int *n);
01976 
01977 /* deprecated function. */ 
01978 GM_ENTRY_POINT gm_status_t gm_max_node_id_inuse (struct gm_port *port,
01979                                                  unsigned int *n);
01980 
01982 GM_ENTRY_POINT int gm_memcmp (const void *a, const void *b, gm_size_t len);
01983 
01986 GM_ENTRY_POINT void *gm_memorize_message (void *message, void *buffer,
01987                                           unsigned int len);
01988 
01991 GM_ENTRY_POINT unsigned int gm_min_message_size (struct gm_port *port);
01992 
01995 GM_ENTRY_POINT unsigned int gm_min_size_for_length (gm_size_t length);
01996 
01998 GM_ENTRY_POINT unsigned int gm_mtu (struct gm_port *port);
01999 
02004 GM_ENTRY_POINT char *gm_node_id_to_host_name (struct gm_port *port,
02005                                               unsigned int node_id);
02006 
02009 GM_ENTRY_POINT gm_status_t gm_node_id_to_unique_id (struct gm_port *port,
02010                                                     unsigned int n,
02011                                                     char unique[6]);
02012 
02015 GM_ENTRY_POINT unsigned int gm_num_ports (struct gm_port *p);
02016 
02019 GM_ENTRY_POINT unsigned int gm_num_send_tokens (struct gm_port *p);
02020 
02023 GM_ENTRY_POINT unsigned int gm_num_receive_tokens (struct gm_port *p);
02024 
02026 GM_ENTRY_POINT unsigned int gm_get_port_id(struct gm_port *p);
02027 
02029 GM_ENTRY_POINT gm_status_t gm_open (struct gm_port **p, unsigned int unit,
02030                                     unsigned int port, const char *port_name,
02031                                     enum gm_api_version version);
02032 
02033 /* Deprecated function. */
02034 GM_ENTRY_POINT void gm_provide_receive_buffer (struct gm_port *p, void *ptr,
02035                                                unsigned int size,
02036                                                unsigned int priority);
02037 
02040 GM_ENTRY_POINT void gm_provide_receive_buffer_with_tag (struct gm_port *p,
02041                                                         void *ptr,
02042                                                         unsigned int size,
02043                                                         unsigned int priority,
02044                                                         unsigned int tag);
02045 
02048 GM_ENTRY_POINT int gm_receive_pending (struct gm_port *p);
02049 
02052 GM_ENTRY_POINT int gm_next_event_peek (struct gm_port *p, gm_u16_t *sender);
02053 
02055 GM_ENTRY_POINT union gm_recv_event *gm_receive (struct gm_port *p);
02056 
02059 GM_ENTRY_POINT gm_status_t gm_register_memory (struct gm_port *p,
02060                                                void *ptr, gm_size_t length);
02061 
02064 GM_ENTRY_POINT int gm_send_token_available (struct gm_port *p,
02065                                             unsigned int priority);
02066 
02067 /* Deprecated function. */
02068 GM_ENTRY_POINT void gm_send (struct gm_port *p, void *message,
02069                              unsigned int size, gm_size_t len,
02070                              unsigned int priority,
02071                              unsigned int target_node_id,
02072                              unsigned int target_port_id);
02073 
02075 GM_ENTRY_POINT
02076 void gm_send_with_callback (struct gm_port *p, void *message,
02077                             unsigned int size, gm_size_t len,
02078                             unsigned int priority,
02079                             unsigned int target_node_id,
02080                             unsigned int target_port_id,
02081                             gm_send_completion_callback_t callback,
02082                             void *context);
02083 
02084 /* Deprecated function. */
02085 GM_ENTRY_POINT void gm_send_to_peer (struct gm_port *p, void *message,
02086                                      unsigned int size, gm_size_t len,
02087                                      unsigned int priority,
02088                                      unsigned int target_node_id);
02089 
02092 GM_ENTRY_POINT
02093 void gm_send_to_peer_with_callback (struct gm_port *p, void *message,
02094                                     unsigned int size, gm_size_t len,
02095                                     unsigned int priority,
02096                                     unsigned int target_node_id,
02097                                     gm_send_completion_callback_t callback,
02098                                     void *context);
02099 
02102 GM_ENTRY_POINT gm_status_t gm_set_acceptable_sizes (struct gm_port *p,
02103                                                     enum gm_priority
02104                                                     priority, gm_size_t mask);
02105 
02108 GM_ENTRY_POINT void gm_set_alarm (struct gm_port *p,
02109                                   struct gm_alarm *my_alarm,
02110                                   gm_u64_t usecs,
02111                                   void (*callback) (void *), void *context);
02112 
02114 GM_ENTRY_POINT gm_size_t gm_strlen (const char *cptr);
02115 
02117 GM_ENTRY_POINT char *gm_strncpy (char *to, const char *from, int len);
02118 
02120 GM_ENTRY_POINT int gm_strcmp (const char *a, const char *b);
02121 
02123 GM_ENTRY_POINT int gm_strncmp (const char *a, const char *b, int len);
02124 
02126 GM_ENTRY_POINT int gm_strncasecmp (const char *a, const char *b, int len);
02127 
02130 GM_ENTRY_POINT gm_u64_t gm_ticks (struct gm_port *port);
02131 
02134 GM_ENTRY_POINT gm_status_t gm_unique_id (struct gm_port *port,
02135                                          char unique[6]);
02136 
02139 GM_ENTRY_POINT gm_status_t gm_unique_id_to_node_id (struct gm_port *port,
02140                                                     char unique[6],
02141                                                     unsigned int *node_id);
02142 
02144 GM_ENTRY_POINT void gm_unknown (struct gm_port *p, union gm_recv_event *e);
02145 
02147 GM_ENTRY_POINT gm_status_t _gm_get_route (struct gm_port *p,
02148                                           unsigned int node_id, char *route,
02149                                           unsigned int *len);
02150 
02151 /****************
02152  * buffer debugging
02153  ****************/
02154 
02156 GM_ENTRY_POINT void gm_dump_buffers (void);
02157 
02159 GM_ENTRY_POINT void gm_register_buffer (void *addr, int size);
02160 
02162 GM_ENTRY_POINT int gm_unregister_buffer (void *addr, int size);
02163 
02164 /************
02165  * Lookaside table entry points
02166  ************/
02167 
02169 GM_ENTRY_POINT struct gm_lookaside *gm_create_lookaside (gm_size_t entry_len,
02170                                                          gm_size_t
02171                                                          min_entry_cnt);
02172 
02174 GM_ENTRY_POINT void gm_destroy_lookaside (struct gm_lookaside *l);
02175 
02178 GM_ENTRY_POINT void *gm_lookaside_alloc (struct gm_lookaside *l);
02179 
02182 GM_ENTRY_POINT void *gm_lookaside_zalloc (struct gm_lookaside *l);
02183 
02186 GM_ENTRY_POINT void gm_lookaside_free (void *ptr);
02187 
02188 /************
02189  * Hash table entry points
02190  ************/
02191 
02192 #define GM_HASH_SMOOTH 1        /* not yet supported */
02193 
02195 GM_ENTRY_POINT struct gm_hash
02196   *gm_create_hash (long (*gm_user_compare) (void *key1, void *key2),
02197                    unsigned long (*gm_user_hash) (void *key1),
02198                    gm_size_t key_len, gm_size_t data_len,
02199                    gm_size_t gm_min_entries, int flags);
02200 
02202 GM_ENTRY_POINT void gm_destroy_hash (struct gm_hash *h);
02203 
02205 GM_ENTRY_POINT void *gm_hash_remove (struct gm_hash *hash, void *key);
02206 
02208 GM_ENTRY_POINT void *gm_hash_find (struct gm_hash *hash, void *key);
02209 
02211 GM_ENTRY_POINT gm_status_t gm_hash_insert (struct gm_hash *hash, void *key,
02212                                            void *datum);
02213 
02215 GM_ENTRY_POINT void gm_hash_rekey (struct gm_hash *hash, void *old_key,
02216                                    void *new_key);
02217 
02220 GM_ENTRY_POINT long gm_hash_compare_strings (void *key1, void *key2);
02221 
02223 GM_ENTRY_POINT unsigned long gm_hash_hash_string (void *key);
02224 
02227 GM_ENTRY_POINT long gm_hash_compare_longs (void *key1, void *key2);
02228 
02230 GM_ENTRY_POINT unsigned long gm_hash_hash_long (void *key);
02231 
02234 GM_ENTRY_POINT long gm_hash_compare_ints (void *key1, void *key2);
02235 
02237 GM_ENTRY_POINT unsigned long gm_hash_hash_int (void *key);
02238 
02241 GM_ENTRY_POINT long gm_hash_compare_ptrs (void *key1, void *key2);
02242 
02244 GM_ENTRY_POINT unsigned long gm_hash_hash_ptr (void *key);
02245 
02246 /************
02247  * crc
02248  ************/
02249 
02251 GM_ENTRY_POINT unsigned long gm_crc (void *ptr, gm_size_t len);
02252 
02254 GM_ENTRY_POINT unsigned long gm_crc_str (const char *ptr);
02255 
02256 /************
02257  * random number generation
02258  ************/
02259 
02261 GM_ENTRY_POINT int gm_rand (void);
02262 
02264 GM_ENTRY_POINT void gm_srand (int seed);
02265 
02267 GM_ENTRY_POINT unsigned int gm_rand_mod (unsigned int modulus);
02268 
02269 /************
02270  * init/finalize
02271  ************/
02272 
02274 GM_ENTRY_POINT gm_status_t gm_init (void);
02275 
02279 GM_ENTRY_POINT void gm_finalize (void);
02280 
02281 /************
02282  * base 2 logarithm computation
02283  ************/
02284 
02286 GM_ENTRY_POINT extern const unsigned char gm_log2_roundup_table[257];
02287 
02289 GM_ENTRY_POINT unsigned long gm_log2_roundup (unsigned long n);
02290 
02291 /************
02292  * GM mutex's (currently open-coded for user-mode)
02293  ************/
02294 
02296 GM_ENTRY_POINT struct gm_mutex *gm_create_mutex (void);
02297 
02299 GM_ENTRY_POINT void gm_destroy_mutex (struct gm_mutex *mu);
02300 
02302 GM_ENTRY_POINT void gm_mutex_enter (struct gm_mutex *mu);
02303 
02305 GM_ENTRY_POINT void gm_mutex_exit (struct gm_mutex *mu);
02306 
02307 /************
02308  * GM zone
02309  ************/
02310 
02312 GM_ENTRY_POINT struct gm_zone *gm_zone_create_zone (void *base,
02313                                                     gm_size_t len);
02314 
02316 GM_ENTRY_POINT void gm_zone_destroy_zone (struct gm_zone *zone);
02317 
02319 GM_ENTRY_POINT void *gm_zone_free (struct gm_zone *zone, void *a);
02320 
02322 GM_ENTRY_POINT void *gm_zone_malloc (struct gm_zone *zone, gm_size_t length);
02323 
02325 GM_ENTRY_POINT void *gm_zone_calloc (struct gm_zone *zone, gm_size_t count,
02326                                      gm_size_t length);
02327 
02329 GM_ENTRY_POINT int gm_zone_addr_in_zone (struct gm_zone *zone, void *p);
02330 
02331 /****************
02332  * Default event handlers.
02333  *
02334  * gm_unknown() will call these for you, but you can call them directly
02335  * to enhance performance.
02336  ****************/
02337 
02338 /* Deprecated function. */
02339 GM_ENTRY_POINT void
02340 gm_handle_put_notification (struct gm_port *p, gm_recv_event_t * e);
02341 /* Deprecated function. */
02342 GM_ENTRY_POINT void gm_handle_sent_tokens (struct gm_port *p,
02343                                            gm_recv_event_t * e);
02344 
02345 /****************
02346  * fault tolerance
02347  ****************/
02348 
02351 GM_ENTRY_POINT void gm_resume_sending (struct gm_port *p,
02352                                        unsigned int priority,
02353                                        unsigned int target_node_id,
02354                                        unsigned int target_port_id,
02355                                        gm_send_completion_callback_t callback,
02356                                        void *context);
02357 
02360 GM_ENTRY_POINT void gm_drop_sends (struct gm_port *port,
02361                                    unsigned int priority,
02362                                    unsigned int target_node_id,
02363                                    unsigned int target_port_id,
02364                                    gm_send_completion_callback_t callback,
02365                                    void *context);
02366 
02367 /****************
02368  * PID support
02369  ****************/
02370 
02372 typedef gm_u32_t gm_pid_t;
02373 
02375 GM_ENTRY_POINT gm_pid_t gm_getpid (void);
02376 
02377 /****************
02378  * Direct copy support
02379  ****************/
02380 
02383 GM_ENTRY_POINT gm_status_t gm_directcopy_get (struct gm_port *p,
02384                                               void *source_addr,
02385                                               void *target_addr,
02386                                               gm_size_t length,
02387                                               unsigned int source_instance_id,
02388                                               unsigned int source_port_id);
02389 
02390 /****************
02391  * Misc
02392  ****************/
02393 
02395 GM_ENTRY_POINT void gm_perror (const char *message, gm_status_t error);
02396 
02398 GM_ENTRY_POINT int gm_sleep (unsigned seconds);
02399 
02402 GM_ENTRY_POINT void gm_exit (gm_status_t status);
02403 
02406 GM_ENTRY_POINT int
02407 gm_printf (const char *format, ...)
02408 #ifdef __GNUC__
02409   __attribute__ ((format (printf, 1, 2)))
02410 #endif
02411   ;
02412 
02413 /****************************************************************
02414  * GM-1.4 additions
02415  ****************************************************************/
02416 
02417 #if GM_API_VERSION >= GM_API_VERSION_1_4
02418 
02420 GM_ENTRY_POINT char *gm_strerror (gm_status_t error);
02421 
02423 GM_ENTRY_POINT gm_status_t gm_set_enable_nack_down(struct gm_port *port,
02424                                                    int flag);
02425 
02428 GM_ENTRY_POINT gm_status_t gm_max_node_id_in_use (struct gm_port *port,
02429                                                   unsigned int *n);
02430 #endif
02431 
02432 /****************
02433  * GM-1.6 additions
02434  ****************/
02435 
02436 #if GM_API_VERSION >= GM_API_VERSION_1_6
02437   
02438 #define GM_STRUCT_CONTAINING(type,field,field_instance)                 \
02439 ((type *)((char *)(field_instance) - GM_OFFSETOF (type, field)))
02440 #define GM_NUM_ELEM(ar) (sizeof (ar) / sizeof (*ar))
02441 #define GM_POWER_OF_TWO(n) (!((n)&((n)-1)))
02442 #define GM_MISALIGNMENT(n,m) __GM_MISALIGNMENT(n,m)
02443 
02445 GM_ENTRY_POINT int gm_eprintf (const char *format, ...)
02446 #ifdef __GNUC__
02447   __attribute__ ((format (printf, 1, 2)))
02448 #endif
02449   ;
02450 
02452 GM_ENTRY_POINT void *gm_memset (void *s, int c, gm_size_t n);
02453 
02455 GM_ENTRY_POINT char *gm_strdup (const char *);
02456 
02457 #endif
02458 
02459 /****************
02460  * GM mark support
02461  ****************/
02462 
02463 typedef gm_size_t gm_mark_t;
02464 struct gm_mark_set;
02465 
02467 GM_ENTRY_POINT gm_status_t gm_mark (struct gm_mark_set *set, gm_mark_t *m);
02468 
02470 GM_ENTRY_POINT int gm_mark_is_valid (struct gm_mark_set *set, gm_mark_t *m);
02471 
02473 GM_ENTRY_POINT gm_status_t gm_create_mark_set (struct gm_mark_set **set,
02474                                                unsigned long init_count);
02475 
02477 GM_ENTRY_POINT void gm_destroy_mark_set (struct gm_mark_set *set);
02478 
02480 GM_ENTRY_POINT void gm_unmark (struct gm_mark_set *set, gm_mark_t *m);
02481 
02483 GM_ENTRY_POINT void gm_unmark_all (struct gm_mark_set *set);
02484 
02485 /****************
02486  * gm_on_exit
02487  ****************/
02488 
02489 typedef void (*gm_on_exit_callback_t)(gm_status_t status, void *arg);
02490 
02494 GM_ENTRY_POINT gm_status_t gm_on_exit (gm_on_exit_callback_t, void *arg);
02495 
02496 /****************************************************************
02497  * GM-2.0 new entry points
02498  ****************************************************************/
02499 
02500 #if GM_API_VERSION >= GM_API_VERSION_2_0
02501 
02503 GM_ENTRY_POINT void gm_get (struct gm_port *p,
02504                             gm_remote_ptr_t remote_buffer,
02505                             void *local_buffer,
02506                             gm_size_t len,
02507                             enum gm_priority priority,
02508                             unsigned int target_node_id,
02509                             unsigned int target_port_id,
02510                             gm_send_completion_callback_t callback,
02511                             void *context);
02512 
02514 GM_ENTRY_POINT void gm_put (struct gm_port *p,
02515                             void *local_buffer,
02516                             gm_remote_ptr_t remote_buffer,
02517                             gm_size_t len,
02518                             enum gm_priority priority,
02519                             unsigned int target_node_id,
02520                             unsigned int target_port_id,
02521                             gm_send_completion_callback_t callback,
02522                             void *context);
02523 
02525 GM_ENTRY_POINT char *gm_strdup (const char *);
02526 
02528 GM_ENTRY_POINT int gm_eprintf (const char *format, ...);
02529 
02532 #define GM_STRUCT_CONTAINING(type,field,field_instance)                 \
02533 ((type *)((char *)(field_instance) - GM_OFFSETOF (type, field)))
02534 
02536 #define GM_NUM_ELEM(ar) (sizeof (ar) / sizeof (*ar))
02537 
02540 #define GM_POWER_OF_TWO(n) (!((n)&((n)-1)))
02541 
02545 GM_ENTRY_POINT gm_status_t gm_global_id_to_node_id (struct gm_port *port,
02546                                                     unsigned int global_id,
02547                                                     unsigned int *node_id);
02548 
02552 GM_ENTRY_POINT gm_status_t gm_node_id_to_global_id (struct gm_port *port,
02553                                                     unsigned int node_id,
02554                                                     unsigned int *global_id);
02555 
02559 GM_ENTRY_POINT gm_status_t gm_node_id_to_host_name_ex (struct gm_port *port,
02560                                                        unsigned int
02561                                                        timeout_usecs,
02562                                                        unsigned int node_id,
02563                                                        char (*name)
02564                                                        [GM_MAX_HOST_NAME_LEN+1]
02565                                                        );
02569 GM_ENTRY_POINT gm_status_t gm_host_name_to_node_id_ex (struct gm_port *port,
02570                                                        unsigned int
02571                                                        timeout_usecs,
02572                                                        const char *host_name,
02573                                                        unsigned int *node_id);
02574 
02575 #endif /* GM_API_VERSION >= GM_API_VERSION_2_0 */
02576 
02577 #if GM_API_VERSION >= GM_API_VERSION_2_0_6
02578 GM_ENTRY_POINT gm_status_t gm_register_memory_ex (struct gm_port *p,
02579                                                   void *ptr, gm_size_t length,
02580                                                   void *pvma);
02581 #endif /* GM_API_VERSION >= GM_API_VERSION_2_0_6 */
02582 
02583 
02584 /****************************************************************
02585  * Warning suppression
02586  ****************************************************************/
02587 
02588 /****************
02589  * Intel compiler
02590  ****************/
02591 
02592 /* Trick the Intel compiler into not emitting Remark #177 about functions
02593    being declared but never referenced. */
02594 
02595 #if defined __INTEL_COMPILER
02596 
02597 extern gm_u8_t  __gm_u8;
02598 extern gm_u16_t __gm_u16;
02599 extern gm_u32_t __gm_u32;
02600 extern gm_u64_t __gm_u64;
02601 
02602 extern gm_s8_t  __gm_s8;
02603 extern gm_s16_t __gm_s16;
02604 extern gm_s32_t __gm_s32;
02605 extern gm_s64_t __gm_s64;
02606 
02607 extern gm_u8_n_t  __gm_u8_n;
02608 extern gm_u16_n_t __gm_u16_n;
02609 extern gm_u32_n_t __gm_u32_n;
02610 extern gm_u64_n_t __gm_u64_n;
02611 
02612 extern gm_s8_n_t  __gm_s8_n;
02613 extern gm_s16_n_t __gm_s16_n;
02614 extern gm_s32_n_t __gm_s32_n;
02615 extern gm_s64_n_t __gm_s64_n;
02616 
02617 extern void *__gm_void_p;
02618 extern gm_up_n_t __gm_up_n;
02619 
02620 static inline
02621 void
02622 __gm_suppress_intel_compiler_warnings ()
02623 {
02624   __gm_s8 = gm_ntoh_s8 (__gm_s8_n);
02625   __gm_s16 = gm_ntoh_s16 (__gm_s16_n);
02626   __gm_s32 = gm_ntoh_s32 (__gm_s32_n);
02627   __gm_s64 = gm_ntoh_s64 (__gm_s64_n);
02628 
02629   __gm_u8 = gm_ntoh_u8 (__gm_u8_n);
02630   __gm_u16 = gm_ntoh_u16 (__gm_u16_n);
02631   __gm_u32 = gm_ntoh_u32 (__gm_u32_n);
02632   __gm_u64 = gm_ntoh_u64 (__gm_u64_n);
02633 
02634   __gm_s8_n = gm_hton_s8 (__gm_s8);
02635   __gm_s16_n = gm_hton_s16 (__gm_s16);
02636   __gm_s32_n = gm_hton_s32 (__gm_s32);
02637   __gm_s64_n = gm_hton_s64 (__gm_s64);
02638 
02639   __gm_u8_n = gm_hton_u8 (__gm_u8);
02640   __gm_u16_n = gm_hton_u16 (__gm_u16);
02641   __gm_u32_n = gm_hton_u32 (__gm_u32);
02642   __gm_u64_n = gm_hton_u64 (__gm_u64);
02643 
02644   __gm_u32 = __gm_swap_u32_asm (__gm_u32);
02645   __gm_u32 = gm_htopci_u32 (__gm_u32);
02646 
02647 #if !GM_BUILDING_GM
02648   __gm_u8 = gm_ntohc (__gm_u8_n);
02649   __gm_u16 = gm_ntohs (__gm_u16_n);
02650   __gm_u32 = gm_ntohl (__gm_u32_n);
02651   __gm_u64 = gm_ntohll (__gm_u64_n);
02652 
02653   __gm_u8_n = gm_htonc (__gm_u8);
02654   __gm_u16_n = gm_htons (__gm_u16);
02655   __gm_u32_n = gm_htonl (__gm_u32);
02656   __gm_u64_n = gm_htonll (__gm_u64);
02657 
02658   __gm_void_p = gm_ntohp (__gm_up_n);
02659 #endif /* !GM_BUILDING_GM */
02660   
02661   __gm_suppress_intel_compiler_warnings ();
02662 }
02663 
02664 #endif /* defined __INTEL_COMPILER */
02665 
02666 /************************************************************************
02667  * Epilogue
02668  ************************************************************************/
02669 
02670 #ifdef __cplusplus
02671 #if 0
02672 {                               /* indent hack */
02673 #endif
02674 }
02675 #endif
02676 
02677 #endif /* ifndef _gm_h_ */
02678 
02679 /*
02680   This file uses GM standard indentation:
02681 
02682   Local Variables:
02683   c-file-style:"gnu"
02684   tab-width:8
02685   End:
02686 */

Generated on Mon Nov 3 15:39:25 2003 for GM by doxygen1.2.15