00001
00002 #ifndef _EDT_BF_H_
00003 #define _EDT_BF_H_
00004
00005 #ifdef __cplusplus
00006 extern "C" {
00007 #endif
00008
00013
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
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;
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 u_int full_buffer_size;
00056 int buffer_allocated;
00057 u_char *full_buffer;
00058 u_int cur_index;
00059 u_char *data;
00060 u_int data_size;
00061 HANDLE f;
00062
00063 EdtBitfileHeader hdr;
00064
00065 }EdtBitfile;
00066
00067
00068
00069
00070 typedef struct _bitfile_list {
00071 int nbfiles;
00072 EdtBitfileHeader *bitfiles;
00073 } EdtBitfileList;
00074
00075
00076
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
00112
00113
00114
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, u_int size, int channel);
00145 EDTAPI void edt_bitfile_destroy(EdtBitfile *bfd);
00146
00147 #ifdef DO_DIRECT_LOAD
00148 EDTAPI int edt_program_flash_direct(EdtDev *edt_p, const u_char *buf, int size, int do_sleep);
00149 EDTAPI int edt_program_mezzanine_direct(EdtDev *edt_p, const u_char *buf, int size, int channel);
00150 #endif
00151
00156 EDTAPI int edt_bitload(EdtDev *edt_p, const char *basedir, const char *fname, int flags, int skip);
00157 EDTAPI int edt_bitload_from_prom(EdtDev *edt_p, u_int addr1, int size1, u_int addr2, int sized, int flags);
00159
00160 EDTAPI int bitload_has_slashes(const char *name);
00161
00162 void EDTAPI edt_bitload_devid_to_bitdir(int id, char *devdir);
00163 EDTAPI int edt_get_x_header(FILE * xfile, char *header, int *size);
00164
00165
00166 #define BITLOAD_FLAGS_NOFS 0x1
00167 #define BITLOAD_FLAGS_OVR 0x2
00168 #define BITLOAD_FLAGS_CH1 0x8
00170 #define BITLOAD_FLAGS_READBACK 0x20
00171
00172 #define BITLOAD_FLAGS_SLEEP 0x40
00173
00174 #define BITLOAD_FLAGS_MEZZANINE 0x4
00175 #define BITLOAD_FLAGS_OCM 0x4
00176 #define BITLOAD_FLAGS_SRXL 0x10
00179
00180 #define ALT_INTERFACE 0
00181 #define ALT_MEZZANINE 1
00182
00183 EDTAPI int edt_bitfile_load_file(EdtBitfile *bfd, const char *name);
00184 EDTAPI int edt_bitfile_load_array(EdtBitfile *bfd, u_char *data, int size);
00185 EDTAPI int edt_bitfile_open_file(EdtBitfile *bfd, const char *name, u_char writing);
00186 EDTAPI void edt_bitfile_init(EdtBitfile *bitfile);
00187
00188 EDTAPI void ensure_bitfile_name(const char *name, char *bitname);
00189 EDTAPI int edt_get_x_array_header(u_char *ba,
00190 char *header,
00191 int *size);
00192
00193
00194
00195
00196 #ifdef __linux__
00197 #ifdef PCD
00198 #ifndef _KERNEL
00199 #define DO_DIRECT_LOAD
00200 #endif
00201 #endif
00202 #endif
00203
00204 #ifdef __cplusplus
00205 }
00206 #endif
00207
00208 #endif
00209
00210