| 1 | /****************************************************************************/ | 
|---|
| 2 | /*                                                                                                                                                      */ | 
|---|
| 3 | /*      Module:                 jbiexprt.h                                                                                              */ | 
|---|
| 4 | /*                                                                                                                                                      */ | 
|---|
| 5 | /*                                      Copyright (C) Altera Corporation 1998-2001                              */ | 
|---|
| 6 | /*                                                                                                                                                      */ | 
|---|
| 7 | /*      Description:    Jam STAPL ByteCode Player Export Header File                    */ | 
|---|
| 8 | /*                                                                                                                                                      */ | 
|---|
| 9 | /*      Revisions:                                                                                                                              */ | 
|---|
| 10 | /*                                                                                                                                                      */ | 
|---|
| 11 | /****************************************************************************/ | 
|---|
| 12 |  | 
|---|
| 13 | #ifndef INC_JBIEXPRT_H | 
|---|
| 14 | #define INC_JBIEXPRT_H | 
|---|
| 15 |  | 
|---|
| 16 | /****************************************************************************/ | 
|---|
| 17 | /*                                                                                                                                                      */ | 
|---|
| 18 | /*      Return codes from most JBI functions                                                                    */ | 
|---|
| 19 | /*                                                                                                                                                      */ | 
|---|
| 20 | /****************************************************************************/ | 
|---|
| 21 |  | 
|---|
| 22 | #define JBI_RETURN_TYPE int | 
|---|
| 23 |  | 
|---|
| 24 | #define JBIC_SUCCESS            0 | 
|---|
| 25 | #define JBIC_OUT_OF_MEMORY      1 | 
|---|
| 26 | #define JBIC_IO_ERROR           2 | 
|---|
| 27 | /* #define JAMC_SYNTAX_ERROR       3 */ | 
|---|
| 28 | #define JBIC_UNEXPECTED_END     4 | 
|---|
| 29 | #define JBIC_UNDEFINED_SYMBOL   5 | 
|---|
| 30 | /* #define JAMC_REDEFINED_SYMBOL   6 */ | 
|---|
| 31 | #define JBIC_INTEGER_OVERFLOW   7 | 
|---|
| 32 | #define JBIC_DIVIDE_BY_ZERO     8 | 
|---|
| 33 | #define JBIC_CRC_ERROR          9 | 
|---|
| 34 | #define JBIC_INTERNAL_ERROR    10 | 
|---|
| 35 | #define JBIC_BOUNDS_ERROR      11 | 
|---|
| 36 | /* #define JAMC_TYPE_MISMATCH     12 */ | 
|---|
| 37 | /* #define JAMC_ASSIGN_TO_CONST   13 */ | 
|---|
| 38 | /* #define JAMC_NEXT_UNEXPECTED   14 */ | 
|---|
| 39 | /* #define JAMC_POP_UNEXPECTED    15 */ | 
|---|
| 40 | /* #define JAMC_RETURN_UNEXPECTED 16 */ | 
|---|
| 41 | /* #define JAMC_ILLEGAL_SYMBOL    17 */ | 
|---|
| 42 | #define JBIC_VECTOR_MAP_FAILED 18 | 
|---|
| 43 | #define JBIC_USER_ABORT        19 | 
|---|
| 44 | #define JBIC_STACK_OVERFLOW    20 | 
|---|
| 45 | #define JBIC_ILLEGAL_OPCODE    21 | 
|---|
| 46 | /* #define JAMC_PHASE_ERROR       22 */ | 
|---|
| 47 | /* #define JAMC_SCOPE_ERROR       23 */ | 
|---|
| 48 | #define JBIC_ACTION_NOT_FOUND  24 | 
|---|
| 49 |  | 
|---|
| 50 | /****************************************************************************/ | 
|---|
| 51 | /*                                                                                                                                                      */ | 
|---|
| 52 | /*      Macro Definitions                                                                                                               */ | 
|---|
| 53 | /*                                                                                                                                                      */ | 
|---|
| 54 | /****************************************************************************/ | 
|---|
| 55 |  | 
|---|
| 56 | /* | 
|---|
| 57 | *       For DOS port, program data is stored in a set of 16K pages, accessed | 
|---|
| 58 | *       through a pointer table.  For 32-bit version, the buffer is continuous. | 
|---|
| 59 | *       The macro GET_BYTE gets a single byte for either case. | 
|---|
| 60 | */ | 
|---|
| 61 |  | 
|---|
| 62 | #define PROGRAM_PTR unsigned char * | 
|---|
| 63 |  | 
|---|
| 64 | #define GET_BYTE(x) (program[x]) | 
|---|
| 65 |  | 
|---|
| 66 | #define GET_WORD(x) \ | 
|---|
| 67 | (((((unsigned short) GET_BYTE(x)) << 8) & 0xFF00) | \ | 
|---|
| 68 | (((unsigned short) GET_BYTE((x)+1)) & 0x00FF)) | 
|---|
| 69 |  | 
|---|
| 70 | #define GET_DWORD(x) \ | 
|---|
| 71 | (((((unsigned long) GET_BYTE(x)) << 24L) & 0xFF000000L) | \ | 
|---|
| 72 | ((((unsigned long) GET_BYTE((x)+1)) << 16L) & 0x00FF0000L) | \ | 
|---|
| 73 | ((((unsigned long) GET_BYTE((x)+2)) << 8L) & 0x0000FF00L) | \ | 
|---|
| 74 | (((unsigned long) GET_BYTE((x)+3)) & 0x000000FFL)) | 
|---|
| 75 |  | 
|---|
| 76 | /****************************************************************************/ | 
|---|
| 77 | /*                                                                                                                                                      */ | 
|---|
| 78 | /*      Structured Types                                                                                                                */ | 
|---|
| 79 | /*                                                                                                                                                      */ | 
|---|
| 80 | /****************************************************************************/ | 
|---|
| 81 |  | 
|---|
| 82 | typedef struct JBI_PROCINFO_STRUCT | 
|---|
| 83 | { | 
|---|
| 84 | char *name; | 
|---|
| 85 | unsigned char attributes; | 
|---|
| 86 | struct JBI_PROCINFO_STRUCT *next; | 
|---|
| 87 | } | 
|---|
| 88 | JBI_PROCINFO; | 
|---|
| 89 |  | 
|---|
| 90 | /****************************************************************************/ | 
|---|
| 91 | /*                                                                                                                                                      */ | 
|---|
| 92 | /*      Global Data Prototypes                                                                                                  */ | 
|---|
| 93 | /*                                                                                                                                                      */ | 
|---|
| 94 | /****************************************************************************/ | 
|---|
| 95 |  | 
|---|
| 96 | extern PROGRAM_PTR jbi_program; | 
|---|
| 97 |  | 
|---|
| 98 | extern char *jbi_workspace; | 
|---|
| 99 |  | 
|---|
| 100 | extern long jbi_workspace_size; | 
|---|
| 101 |  | 
|---|
| 102 | /****************************************************************************/ | 
|---|
| 103 | /*                                                                                                                                                      */ | 
|---|
| 104 | /*      Function Prototypes                                                                                                             */ | 
|---|
| 105 | /*                                                                                                                                                      */ | 
|---|
| 106 | /****************************************************************************/ | 
|---|
| 107 |  | 
|---|
| 108 | JBI_RETURN_TYPE jbi_execute | 
|---|
| 109 | ( | 
|---|
| 110 | PROGRAM_PTR program, | 
|---|
| 111 | long program_size, | 
|---|
| 112 | char *workspace, | 
|---|
| 113 | long workspace_size, | 
|---|
| 114 | char *action, | 
|---|
| 115 | char **init_list, | 
|---|
| 116 | int reset_jtag, | 
|---|
| 117 | long *error_address, | 
|---|
| 118 | int *exit_code, | 
|---|
| 119 | int *format_version | 
|---|
| 120 | ); | 
|---|
| 121 |  | 
|---|
| 122 | JBI_RETURN_TYPE jbi_get_note | 
|---|
| 123 | ( | 
|---|
| 124 | PROGRAM_PTR program, | 
|---|
| 125 | long program_size, | 
|---|
| 126 | long *offset, | 
|---|
| 127 | char *key, | 
|---|
| 128 | char *value, | 
|---|
| 129 | int length | 
|---|
| 130 | ); | 
|---|
| 131 |  | 
|---|
| 132 | JBI_RETURN_TYPE jbi_check_crc | 
|---|
| 133 | ( | 
|---|
| 134 | PROGRAM_PTR program, | 
|---|
| 135 | long program_size, | 
|---|
| 136 | unsigned short *expected_crc, | 
|---|
| 137 | unsigned short *actual_crc | 
|---|
| 138 | ); | 
|---|
| 139 |  | 
|---|
| 140 | JBI_RETURN_TYPE jbi_get_file_info | 
|---|
| 141 | ( | 
|---|
| 142 | PROGRAM_PTR program, | 
|---|
| 143 | long program_size, | 
|---|
| 144 | int *format_version, | 
|---|
| 145 | int *action_count, | 
|---|
| 146 | int *procedure_count | 
|---|
| 147 | ); | 
|---|
| 148 |  | 
|---|
| 149 | JBI_RETURN_TYPE jbi_get_action_info | 
|---|
| 150 | ( | 
|---|
| 151 | PROGRAM_PTR program, | 
|---|
| 152 | long program_size, | 
|---|
| 153 | int index, | 
|---|
| 154 | char **name, | 
|---|
| 155 | char **description, | 
|---|
| 156 | JBI_PROCINFO **procedure_list | 
|---|
| 157 | ); | 
|---|
| 158 |  | 
|---|
| 159 | void usb_blaster_wait | 
|---|
| 160 | ( | 
|---|
| 161 | int count, | 
|---|
| 162 | int tms | 
|---|
| 163 | ); | 
|---|
| 164 |  | 
|---|
| 165 | void usb_blaster_scan | 
|---|
| 166 | ( | 
|---|
| 167 | int count, | 
|---|
| 168 | unsigned char *tdi, | 
|---|
| 169 | unsigned char *tdo | 
|---|
| 170 | ); | 
|---|
| 171 |  | 
|---|
| 172 | int jbi_jtag_io | 
|---|
| 173 | ( | 
|---|
| 174 | int tms, | 
|---|
| 175 | int tdi, | 
|---|
| 176 | int read_tdo | 
|---|
| 177 | ); | 
|---|
| 178 |  | 
|---|
| 179 | void jbi_message | 
|---|
| 180 | ( | 
|---|
| 181 | char *message_text | 
|---|
| 182 | ); | 
|---|
| 183 |  | 
|---|
| 184 | void jbi_export_integer | 
|---|
| 185 | ( | 
|---|
| 186 | char *key, | 
|---|
| 187 | long value | 
|---|
| 188 | ); | 
|---|
| 189 |  | 
|---|
| 190 | void jbi_export_boolean_array | 
|---|
| 191 | ( | 
|---|
| 192 | char *key, | 
|---|
| 193 | unsigned char *data, | 
|---|
| 194 | long count | 
|---|
| 195 | ); | 
|---|
| 196 |  | 
|---|
| 197 | void jbi_delay | 
|---|
| 198 | ( | 
|---|
| 199 | long microseconds | 
|---|
| 200 | ); | 
|---|
| 201 |  | 
|---|
| 202 | void *jbi_malloc | 
|---|
| 203 | ( | 
|---|
| 204 | unsigned int size | 
|---|
| 205 | ); | 
|---|
| 206 |  | 
|---|
| 207 | void jbi_free | 
|---|
| 208 | ( | 
|---|
| 209 | void *ptr | 
|---|
| 210 | ); | 
|---|
| 211 |  | 
|---|
| 212 | #endif /* INC_JBIEXPRT_H */ | 
|---|