edt_bitload.h

Go to the documentation of this file.
00001 
00002 #ifndef _EDT_BF_H_
00003 #define _EDT_BF_H_
00004 
00005 #ifdef __cplusplus
00006 extern "C" {
00007 #endif
00008 
00013 /* shorthand debug level */
00014 #define DEBUG0 PDVLIB_MSG_FATAL
00015 #define DEBUG1 EDTLIB_MSG_INFO_1
00016 #define DEBUG2 EDTLIB_MSG_INFO_2
00017 
00018 
00019 #ifdef DOXYGEN_SHOW_UNDOC
00020 
00024 #endif
00025 
00026 /* amount to read in for bitfile preamble */
00027 
00028 #define BFH_EXTRASIZE 128
00029 
00030 typedef struct {
00031     char filename[MAXPATH];
00032     u_char fi[8];
00033     u_char ncdname[MAXPATH];
00034     u_char id[32];
00035     u_char date[16];
00036     u_char time[16];
00037     u_int  dsize; /* get_long_size puts 4-byte dsize here */
00038     u_int  filesize;
00039     u_int  key;
00040     int magic;
00041     u_int  data_start;
00042     char promstr[256];
00043     u_char extra[BFH_EXTRASIZE];
00044 } EdtBitfileHeader;
00045 
00051 typedef struct EdtBitfile {
00052     int is_file;
00053     char *filename;
00054     
00055     int full_buffer_size;        /* current size of valid data */
00056     int buffer_allocated;   /* actual allocated size - can be bigger than buffer_size */
00057     u_char *full_buffer;         /* data */
00058     int cur_index;
00059     u_char *data;  /* start of actual data */
00060     int data_size; /* size - header */
00061     HANDLE f;
00062 
00063     EdtBitfileHeader hdr;
00064 
00065 }EdtBitfile;
00066 
00067 /* structure describing a list of bitfiles
00068    with assiocated file header data*/
00069 
00070 typedef struct _bitfile_list {
00071     int nbfiles;
00072     EdtBitfileHeader *bitfiles;
00073 } EdtBitfileList;
00074 
00075 /* structure describing a bitfile and 
00076    carrying the data as file or array */
00077 
00078 #define MAX_CHIPS_PER_ID 16
00079 
00080 typedef struct {
00081     u_int id;
00082     char * fpga_0[MAX_CHIPS_PER_ID];
00083     char * fpga_1[MAX_CHIPS_PER_ID];
00084 } EdtBoardFpgas;
00085 
00086 
00087 extern EDTAPI EdtBoardFpgas board_chips[];
00088 extern EDTAPI EdtBoardFpgas mezz_chips[];
00089 
00090 #if 0
00091 
00092 EDTAPI void sized_buf_init(EdtSizedBuffer *sb);
00093 
00094 EDTAPI void sized_buf_destroy(EdtSizedBuffer *sb);
00095 
00096 EDTAPI int sized_buf_allocate(EdtSizedBuffer *sb, int size);
00097 
00098 #endif
00099 
00100 
00101 EDTAPI void bf_init(EdtBitfileList *bf);
00102 EDTAPI void bf_destroy(EdtBitfileList *bf);
00103 EDTAPI void bf_add_entry(EdtBitfileList *bf, EdtBitfileHeader *bfh);
00104 EDTAPI void bf_check_and_add(EdtBitfileList *bf, const char *fname);
00105 EDTAPI void bf_sort_entries(EdtBitfileList *bf, int override_name);
00106 EDTAPI int bf_allocate(EdtBitfileList *bf, int size);
00107 EDTAPI int bf_allocate_max_buffer(EdtBitfileList *bf, EdtBitfile *data);
00108 EDTAPI const char *
00109 edt_bitload_basedir(EdtDev *edt_p, const char *in, char *out);
00110 
00111 /* gets all possible bitfiles with name fname and stores
00112    them in list bf. If fpga_hint is present, it will be first 
00113    in the list. id is either a board id or a mezzanine id, 
00114    which is used to look up fpga type(s) in the fpga_list.
00115    */
00116 
00117 EDTAPI int edt_get_bitfile_list(const char *basedir,
00118                          const char *devdir,
00119                          const char *fname,
00120                          EdtBoardFpgas *fpga_list,
00121                          int id,
00122                          int channel,
00123                          EdtBitfileList *bf,
00124                          char *fpga_hint);
00125 
00126 EDTAPI int edt_load_mezzfile(EdtDev *edt_p, 
00127                      const char *basedir, 
00128                      const char *bitname, 
00129                      int bitload_flags, 
00130                      int skip_load, 
00131                      int channel);
00132 
00133 EDTAPI int edt_bitfile_read_header(const char *bitpath, 
00134                                    EdtBitfileHeader *bfh, 
00135                                    char *header);
00136 
00137 EDTAPI int edt_get_bitfile_header(EdtBitfile *bp,
00138                                   EdtBitfileHeader *bfh);
00139 
00140 
00141 
00142 EDTAPI int edt_access_bitfile(const char *tmppath, int perm);
00143 EDTAPI int edt_oc192_rev2_fname_hack(EdtDev *edt_p, const char *bitname, char *hacked_bitname); 
00144 EDTAPI int edt_program_mezzanine(EdtDev *edt_p, const u_char *buf, int size, int channel);
00145 
00146 #ifdef DO_DIRECT_LOAD
00147 EDTAPI int edt_program_xilinx_direct(EdtDev *edt_p, const u_char *buf, int size, int do_sleep);
00148 EDTAPI int edt_program_mezzanine_direct(EdtDev *edt_p, const u_char *buf, int size, int channel);
00149 #endif
00150 
00155 EDTAPI int edt_bitload(EdtDev *edt_p, const char *basedir, const char *fname, int flags, int skip);
00156 EDTAPI int edt_bitload_from_prom(EdtDev *edt_p, u_int addr1, int size1, u_int addr2, int sized, int flags); /* end dma_init */
00158 
00159 EDTAPI int bitload_has_slashes(const char *name);
00160 
00161 void EDTAPI edt_bitload_devid_to_bitdir(int id, char *devdir);
00162 EDTAPI int edt_get_x_header(FILE * xfile, char *header, int *size);
00163 
00164 /* flag bits to use in flags param to edt_bitload */
00165 #define BITLOAD_FLAGS_NOFS 0x1 
00166 #define BITLOAD_FLAGS_OVR  0x2 
00167 #define BITLOAD_FLAGS_CH1  0x8 
00169 #define BITLOAD_FLAGS_READBACK 0x20
00170 
00171 #define BITLOAD_FLAGS_SLEEP 0x40
00172 
00173 #define BITLOAD_FLAGS_MEZZANINE 0x4 
00174 #define BITLOAD_FLAGS_OCM  0x4 
00175 #define BITLOAD_FLAGS_SRXL 0x10 
00178 /* program method alternatives */
00179 #define ALT_INTERFACE   0 
00180 #define ALT_MEZZANINE   1
00181 
00182 EDTAPI int edt_bitfile_load_file(EdtBitfile *bfd, const char *name);
00183 EDTAPI int edt_bitfile_load_array(EdtBitfile *bfd, u_char *data, int size);
00184 EDTAPI int edt_bitfile_open_file(EdtBitfile *bfd, const char *name, u_char writing);
00185 EDTAPI void edt_bitfile_init(EdtBitfile *bitfile);
00186 
00187 EDTAPI void ensure_bitfile_name(const char *name, char *bitname);
00188 EDTAPI int edt_get_x_array_header(u_char *ba, 
00189                        char *header, 
00190                        int *size);
00191 
00192 /* This does bit load in user space */
00193 /* undefine to do bit load in the driver */
00194 
00195 #ifdef __linux__
00196 #ifdef PCD
00197 #ifndef _KERNEL
00198 #define DO_DIRECT_LOAD
00199 #endif
00200 #endif
00201 #endif
00202 
00203 #ifdef __cplusplus
00204 } /* extern "C" */
00205 #endif 
00206 
00207 #endif
00208 
00209 

Generated on Mon Mar 21 14:14:38 2011 by  doxygen 1.4.7