 
    This directory contains files necessary to support FASTBUS I/O on 
    the Struck SFI for both data acquisition and slow controls.  
    The Makefile contains explicit references to location of RPCGEN compiler, 
    libraries, and include files.  The server files and FASTBUS routines 
    depend upon VxWorks header files (weakly). 
 
    Files:
 
        Makefile        make file
        fb.h            Function prototypes for FASTBUS standard routines
        fbClientLib.c   Client RPC interface routines
        fbRpc.x         RPCGEN remote program interface definition
        fbSrvrLib.c     RPC server routines (interface to standard routines)
        fbp.c           Interactive line mode FASTBUS client (binary: fbp)
        modify_server_code.awk  Script to modify output of RPCGEN

        fbSrvr          FASTBUS Server to be spawned on the VxWorks target 
                        (See NOTE below)
        libfb.a         Client(UNIX) side FASTBUS library.
	libsfifb.o      Server(VxWorks) side FASTBUS library
                        (Not included in this distribution)


    Author: David Abbott
            TJNAF Data Acquisition Group
	    abbottd@jlab.org


    Supported routines:

        C Interface
        -----------

	  #include "fb.h"

          void fbopen(char *server,int *success);

          void fb_init_1(int addr);
          void sfi_error_decode (int flag);

          unsigned long fpac(int pa, int sa);
          unsigned long fpad(int pa, int sa);
          unsigned long fprel();
          unsigned long fpr();
          unsigned long fpw(int data);
          unsigned long fpsaw(int sa);
          unsigned long fprc(int pa, int sa, int *data);
          unsigned long fprd(int pa, int sa, int *data);
          unsigned long fpwc(int pa, int sa, int data);
          unsigned long fpwd(int pa, int sa, int data);
          unsigned long fprcm(int pa, int sa, int *data);
          unsigned long fprdm(int pa, int sa, int *data);
          unsigned long fpwcm(int pa, int sa, int data);
          unsigned long fpwdm(int pa, int sa, int data);
          unsigned long fpbr(int pa, int sa, int *len, int *data);


        Arguments
        ---------

          server = (character) hostname or IP address of the Server machine
          success = (returned) 0 if failure , 1 if success

          pa = primary address (usually slot number except in the case of
                                multilistener calls like fprcm() )

          sa = secondary address (refering to specific FASTBUS slave CSRs or DSRs)

          data = Either (returned) or (passed) depending on whether the function
                 is a read or write routine respectively.

          addr = Base address of SFI as seen by the vxWorks CPU. If 0 then
                 initialization is assumed and the SFI FB sequencer is simply
                 reset and enabled.

          flag = sets various output/reset options
                          0 - default 
                          1 - suppress logMsg messages
                          2 - force reset/enable of sequencer
                          3 - suppress logMsg and reset/enable

          len = (returned) length in longwords of a blocktransfer


        Notes
        -----

	  The Server 'fbSrvr' must be loaded on the VxWorks target after the SFI FASTBUS
          library (libsfifb.o) as it must be linked against the routines within. The
          Server can be spawned with the following command:
                     taskSpawn("fbServ",120,0,20000,fbSrvr_main)

          A call to fb_init_1(addr) with a non-zero address argument must be made
          at least once after the VxWorks board has been booted. If this was done
          in the board's boot script then it is only necessary in the Client to call
          fb_init_1(0) to ensure the SFI FB sequencer is enabled.

	  All FASTBUS functions returning a value other than 0 indicate that an error
          occured (except fpr()) during the transaction. The function sfi_error_decode() 
          must be called to determine what error occured and to reset the SFIs FB Sequencer. 
          Currently, a description of the error is printed to stdout and not returned to 
          the Client so one must either have CMLOG messaging running or be logged into the 
          VxWorks board to see what error occured.

          FASTBUS Block transfers are currently limited to 100 longwords. This
          should be sufficent to read any single slave board, but would not facilitate
          some uses of the FASTBUS MultiBlock transfer mode.

