Main Page | Alphabetical List | Class List | File List | Class Members | File Members

ildg.h

Go to the documentation of this file.
00001 /* =============
00002  * apeNEXT/nlibc
00003  * =============
00004  *
00005  * Functions needed to read binary files conforming to ILDG stanards
00006  *
00007  * $Id: ildg.h,v 1.2 2006/06/15 18:25:26 pleiter Exp $
00008  * -------------------------------------------------------------------------- */
00009 
00010 #ifndef _NLIBC_OS1_ILDG_H
00011 #define _NLIBC_OS1_ILDG_H
00012 
00013 #include <nsys.h>
00014 #include <lime.h>
00015 #include <string.h>
00016 
00017 // ILDG specific constants
00018 #define ILDG_FIELD_UNKNOWN      _ILDG_FIELD_UNKNOWN
00019 #define ILDG_FIELD_SU3GAUGE     _ILDG_FIELD_SU3GAUGE
00020 
00022 typedef struct {
00023   uint64_t field;               
00024   uint64_t precision;           
00025   uint64_t lx, ly, lz, lt;      
00026 } IldgFormat;
00027 
00028 
00029 //------------------------------------------------------------------------------
00046 //------------------------------------------------------------------------------
00047 #ifndef __HAS_MAIN
00048 extern int ildgWriteFormat(LimeWriter *, int, int, IldgFormat *);
00049 #else
00050 #if !defined(__cflow_processed) || defined(_uses_ildgWriteFormat_ildg_h)
00051 int ildgWriteFormat(LimeWriter *w, int mbflg, int meflg, IldgFormat *f)
00052 {
00053   LimeRecordHeader *h;
00054   struct {
00055     LimeRecordHeader h;
00056     IldgFormat f;
00057   } msg;
00058   int msglen;
00059   vector int sys_rval;
00060 
00061   if (w == NULL || w->fp == NULL || f == NULL) {
00062     return LIME_ERR_PARAM;
00063   }
00064 
00065   // Create lime header (dummy value for number of bytes)
00066   h = limeCreateHeader(mbflg, meflg, "ildg-format", -1);
00067 
00068   // Create message to be sent to frontend
00069   memcpy(&(msg.h), h, sizeof(LimeRecordHeader));
00070   memcpy(&(msg.f), f, 96);
00071   msglen = sizeof(msg);
00072 
00073   // Perform system service
00074   asm("\t$io_start\n"
00075       "\t$io_fd(0.%1)\n"
00076       "\t\\equl $cmd   $SYS_IOCMD_ILDG_FWR\n"
00077       "\t\\equl $fmt   $SYS_IOFMT_BIN\n"
00078       "\t\\equl $dev   $SYS_IODEV_MEM\n"
00079       "\t\\equl $l     %2 >> 4\n"
00080       "\t\\equl $bs    $SYS_IOBS_V\n"
00081       "\t\\equl $rdflg $SYS_IORDFLG_NOP\n"
00082       "\t\\equl $addr  0.%3\n"
00083       "\t$io_packet($cmd, $fmt, $rdflg, $dev, $l, $bs, $addr)\n"
00084       "\t$io_end\n"
00085       "\tlmtr %0 $MEM_SYS_RVAL\n"
00086       : "=r" (sys_rval) : "r" (w->fp->fd), "r" (msglen), "r" (&msg));
00087 
00088   return (int) sys_rval.lo;
00089 }
00090 #endif
00091 #endif
00092 
00093 
00094 //------------------------------------------------------------------------------
00111 //------------------------------------------------------------------------------
00112 #ifndef __HAS_MAIN
00113 extern int ildgReadFormat(LimeReader *, IldgFormat *);
00114 #else
00115 #if !defined(__cflow_processed) || defined(_uses_ildgReadFormat_ildg_h)
00116 int ildgReadFormat(LimeReader *r, IldgFormat *f)
00117 {
00118   int nword;
00119   vector int sys_rval;
00120 
00121   if (r == NULL || r->fp == NULL) {
00122     return LIME_ERR_PARAM;
00123   }
00124 
00125   // Perform system service
00126   nword = sizeof(IldgFormat) >> 4;
00127   asm("\t$io_start\n"
00128       "\t$io_fd(0.%1)\n"
00129       "\t\\equl $cmd   $SYS_IOCMD_ILDG_FRD\n"
00130       "\t\\equl $fmt   $SYS_IOFMT_BIN\n"
00131       "\t\\equl $dev   $SYS_IODEV_MEM\n"
00132       "\t\\equl $l     0.%2\n"
00133       "\t\\equl $bs    $SYS_IOBS_V\n"
00134       "\t\\equl $rdflg $SYS_IORDFLG_NOP\n"
00135       "\t\\equl $addr  0.%3\n"
00136       "\t$io_packet($cmd, $fmt, $rdflg, $dev, $l, $bs, $addr)\n"
00137       "\t$io_end\n"
00138       "\tlmtr %0 $MEM_SYS_RVAL\n"
00139       : "=r" (sys_rval)
00140       : "r" (r->fp->fd), "r" (nword), "r" (f));
00141 
00142   return (int) sys_rval.lo;
00143 }
00144 #endif
00145 #endif
00146 
00147 #endif /* _NLIBC_OS1_ILDG_H */

Generated on Fri Jul 14 10:51:31 2006 for nlibc by doxygen 1.3.5