1 /* 2 * Aic7xxx SCSI host adapter firmware asssembler symbol table definitions 3 * 4 * Copyright (c) 1997 Justin T. Gibbs. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions, and the following disclaimer, 12 * without modification. 13 * 2. The name of the author may not be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $FreeBSD$ 29 */ 30 31 #include <sys/queue.h> 32 33 typedef enum { 34 UNINITIALIZED, 35 REGISTER, 36 ALIAS, 37 SCBLOC, 38 SRAMLOC, 39 MASK, 40 BIT, 41 CONST, 42 DOWNLOAD_CONST, 43 LABEL, 44 CONDITIONAL 45 }symtype; 46 47 typedef enum { 48 RO = 0x01, 49 WO = 0x02, 50 RW = 0x03 51 }amode_t; 52 53 struct reg_info { 54 u_int8_t address; 55 int size; 56 amode_t mode; 57 u_int8_t valid_bitmask; 58 int typecheck_masks; 59 }; 60 61 typedef SLIST_HEAD(symlist, symbol_node) symlist_t; 62 63 struct mask_info { 64 symlist_t symrefs; 65 u_int8_t mask; 66 }; 67 68 struct const_info { 69 u_int8_t value; 70 int define; 71 }; 72 73 struct alias_info { 74 struct symbol *parent; 75 }; 76 77 struct label_info { 78 int address; 79 }; 80 81 struct cond_info { 82 int func_num; 83 }; 84 85 typedef struct expression_info { 86 symlist_t referenced_syms; 87 int value; 88 } expression_t; 89 90 typedef struct symbol { 91 char *name; 92 symtype type; 93 union { 94 struct reg_info *rinfo; 95 struct mask_info *minfo; 96 struct const_info *cinfo; 97 struct alias_info *ainfo; 98 struct label_info *linfo; 99 struct cond_info *condinfo; 100 }info; 101 } symbol_t; 102 103 typedef struct symbol_ref { 104 symbol_t *symbol; 105 int offset; 106 } symbol_ref_t; 107 108 typedef struct symbol_node { 109 SLIST_ENTRY(symbol_node) links; 110 symbol_t *symbol; 111 }symbol_node_t; 112 113 typedef enum { 114 SCOPE_ROOT, 115 SCOPE_IF, 116 SCOPE_ELSE_IF, 117 SCOPE_ELSE 118 } scope_type; 119 120 typedef struct patch_info { 121 int skip_patch; 122 int skip_instr; 123 } patch_info_t; 124 125 typedef struct scope { 126 SLIST_ENTRY(scope) scope_stack_links; 127 TAILQ_ENTRY(scope) scope_links; 128 TAILQ_HEAD(, scope) inner_scope; 129 scope_type type; 130 int inner_scope_patches; 131 int begin_addr; 132 int end_addr; 133 patch_info_t patches[2]; 134 int func_num; 135 } scope_t; 136 137 SLIST_HEAD(scope_list, scope); 138 TAILQ_HEAD(scope_tailq, scope); 139 140 void symbol_delete __P((symbol_t *symbol)); 141 142 void symtable_open __P((void)); 143 144 void symtable_close __P((void)); 145 146 symbol_t * 147 symtable_get __P((char *name)); 148 149 symbol_node_t * 150 symlist_search __P((symlist_t *symlist, char *symname)); 151 152 void 153 symlist_add __P((symlist_t *symlist, symbol_t *symbol, int how)); 154 #define SYMLIST_INSERT_HEAD 0x00 155 #define SYMLIST_SORT 0x01 156 157 void symlist_free __P((symlist_t *symlist)); 158 159 void symlist_merge __P((symlist_t *symlist_dest, symlist_t *symlist_src1, 160 symlist_t *symlist_src2)); 161 void symtable_dump __P((FILE *ofile)); 162