1 1.4 andvar /* $NetBSD: aicasm_symbol.h,v 1.4 2022/05/24 20:50:19 andvar Exp $ */ 2 1.1 fvdl 3 1.1 fvdl /* 4 1.4 andvar * Aic7xxx SCSI host adapter firmware assembler symbol table definitions 5 1.1 fvdl * 6 1.1 fvdl * Copyright (c) 1997 Justin T. Gibbs. 7 1.2 fvdl * Copyright (c) 2002 Adaptec Inc. 8 1.1 fvdl * All rights reserved. 9 1.1 fvdl * 10 1.1 fvdl * Redistribution and use in source and binary forms, with or without 11 1.1 fvdl * modification, are permitted provided that the following conditions 12 1.1 fvdl * are met: 13 1.1 fvdl * 1. Redistributions of source code must retain the above copyright 14 1.1 fvdl * notice, this list of conditions, and the following disclaimer, 15 1.1 fvdl * without modification. 16 1.2 fvdl * 2. Redistributions in binary form must reproduce at minimum a disclaimer 17 1.2 fvdl * substantially similar to the "NO WARRANTY" disclaimer below 18 1.2 fvdl * ("Disclaimer") and any redistribution must be conditioned upon 19 1.2 fvdl * including a substantially similar Disclaimer requirement for further 20 1.2 fvdl * binary redistribution. 21 1.2 fvdl * 3. Neither the names of the above-listed copyright holders nor the names 22 1.2 fvdl * of any contributors may be used to endorse or promote products derived 23 1.2 fvdl * from this software without specific prior written permission. 24 1.1 fvdl * 25 1.2 fvdl * Alternatively, this software may be distributed under the terms of the 26 1.2 fvdl * GNU General Public License ("GPL") version 2 as published by the Free 27 1.2 fvdl * Software Foundation. 28 1.2 fvdl * 29 1.2 fvdl * NO WARRANTY 30 1.2 fvdl * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 31 1.2 fvdl * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 32 1.2 fvdl * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 33 1.2 fvdl * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 34 1.2 fvdl * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35 1.1 fvdl * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36 1.1 fvdl * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 37 1.2 fvdl * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 38 1.2 fvdl * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 39 1.2 fvdl * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 1.2 fvdl * POSSIBILITY OF SUCH DAMAGES. 41 1.1 fvdl * 42 1.2 fvdl * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_symbol.h,v 1.16 2002/08/31 06:39:41 gibbs Exp $ 43 1.1 fvdl */ 44 1.1 fvdl 45 1.2 fvdl #ifdef __linux__ 46 1.2 fvdl #include "../queue.h" 47 1.2 fvdl #else 48 1.1 fvdl #include <sys/queue.h> 49 1.2 fvdl #endif 50 1.1 fvdl 51 1.1 fvdl typedef enum { 52 1.1 fvdl UNINITIALIZED, 53 1.1 fvdl REGISTER, 54 1.1 fvdl ALIAS, 55 1.1 fvdl SCBLOC, 56 1.1 fvdl SRAMLOC, 57 1.2 fvdl ENUM_ENTRY, 58 1.2 fvdl FIELD, 59 1.1 fvdl MASK, 60 1.2 fvdl ENUM, 61 1.1 fvdl CONST, 62 1.1 fvdl DOWNLOAD_CONST, 63 1.1 fvdl LABEL, 64 1.2 fvdl CONDITIONAL, 65 1.2 fvdl MACRO 66 1.2 fvdl } symtype; 67 1.1 fvdl 68 1.1 fvdl typedef enum { 69 1.1 fvdl RO = 0x01, 70 1.1 fvdl WO = 0x02, 71 1.1 fvdl RW = 0x03 72 1.1 fvdl }amode_t; 73 1.1 fvdl 74 1.2 fvdl typedef SLIST_HEAD(symlist, symbol_node) symlist_t; 75 1.2 fvdl 76 1.1 fvdl struct reg_info { 77 1.2 fvdl u_int address; 78 1.2 fvdl int size; 79 1.2 fvdl amode_t mode; 80 1.2 fvdl symlist_t fields; 81 1.2 fvdl uint8_t valid_bitmask; 82 1.2 fvdl uint8_t modes; 83 1.2 fvdl int typecheck_masks; 84 1.1 fvdl }; 85 1.1 fvdl 86 1.2 fvdl struct field_info { 87 1.1 fvdl symlist_t symrefs; 88 1.2 fvdl uint8_t value; 89 1.2 fvdl uint8_t mask; 90 1.1 fvdl }; 91 1.1 fvdl 92 1.1 fvdl struct const_info { 93 1.2 fvdl u_int value; 94 1.2 fvdl int define; 95 1.1 fvdl }; 96 1.1 fvdl 97 1.1 fvdl struct alias_info { 98 1.1 fvdl struct symbol *parent; 99 1.1 fvdl }; 100 1.1 fvdl 101 1.1 fvdl struct label_info { 102 1.1 fvdl int address; 103 1.2 fvdl int exported; 104 1.1 fvdl }; 105 1.1 fvdl 106 1.1 fvdl struct cond_info { 107 1.1 fvdl int func_num; 108 1.1 fvdl }; 109 1.1 fvdl 110 1.2 fvdl struct macro_arg { 111 1.2 fvdl STAILQ_ENTRY(macro_arg) links; 112 1.2 fvdl regex_t arg_regex; 113 1.2 fvdl char *replacement_text; 114 1.2 fvdl }; 115 1.3 ryo STAILQ_HEAD(macro_arg_list, macro_arg); 116 1.2 fvdl 117 1.2 fvdl struct macro_info { 118 1.2 fvdl struct macro_arg_list args; 119 1.2 fvdl int narg; 120 1.2 fvdl const char* body; 121 1.2 fvdl }; 122 1.2 fvdl 123 1.1 fvdl typedef struct expression_info { 124 1.1 fvdl symlist_t referenced_syms; 125 1.1 fvdl int value; 126 1.1 fvdl } expression_t; 127 1.1 fvdl 128 1.1 fvdl typedef struct symbol { 129 1.1 fvdl char *name; 130 1.1 fvdl symtype type; 131 1.1 fvdl union { 132 1.2 fvdl struct reg_info *rinfo; 133 1.2 fvdl struct field_info *finfo; 134 1.1 fvdl struct const_info *cinfo; 135 1.1 fvdl struct alias_info *ainfo; 136 1.1 fvdl struct label_info *linfo; 137 1.2 fvdl struct cond_info *condinfo; 138 1.2 fvdl struct macro_info *macroinfo; 139 1.1 fvdl }info; 140 1.1 fvdl } symbol_t; 141 1.1 fvdl 142 1.1 fvdl typedef struct symbol_ref { 143 1.1 fvdl symbol_t *symbol; 144 1.1 fvdl int offset; 145 1.1 fvdl } symbol_ref_t; 146 1.1 fvdl 147 1.1 fvdl typedef struct symbol_node { 148 1.1 fvdl SLIST_ENTRY(symbol_node) links; 149 1.1 fvdl symbol_t *symbol; 150 1.2 fvdl } symbol_node_t; 151 1.2 fvdl 152 1.2 fvdl typedef struct critical_section { 153 1.2 fvdl TAILQ_ENTRY(critical_section) links; 154 1.2 fvdl int begin_addr; 155 1.2 fvdl int end_addr; 156 1.2 fvdl } critical_section_t; 157 1.1 fvdl 158 1.1 fvdl typedef enum { 159 1.1 fvdl SCOPE_ROOT, 160 1.1 fvdl SCOPE_IF, 161 1.1 fvdl SCOPE_ELSE_IF, 162 1.1 fvdl SCOPE_ELSE 163 1.1 fvdl } scope_type; 164 1.1 fvdl 165 1.1 fvdl typedef struct patch_info { 166 1.1 fvdl int skip_patch; 167 1.1 fvdl int skip_instr; 168 1.1 fvdl } patch_info_t; 169 1.1 fvdl 170 1.1 fvdl typedef struct scope { 171 1.1 fvdl SLIST_ENTRY(scope) scope_stack_links; 172 1.1 fvdl TAILQ_ENTRY(scope) scope_links; 173 1.1 fvdl TAILQ_HEAD(, scope) inner_scope; 174 1.1 fvdl scope_type type; 175 1.1 fvdl int inner_scope_patches; 176 1.1 fvdl int begin_addr; 177 1.1 fvdl int end_addr; 178 1.1 fvdl patch_info_t patches[2]; 179 1.1 fvdl int func_num; 180 1.1 fvdl } scope_t; 181 1.1 fvdl 182 1.2 fvdl TAILQ_HEAD(cs_tailq, critical_section); 183 1.1 fvdl SLIST_HEAD(scope_list, scope); 184 1.1 fvdl TAILQ_HEAD(scope_tailq, scope); 185 1.1 fvdl 186 1.2 fvdl void symbol_delete(symbol_t *symbol); 187 1.1 fvdl 188 1.2 fvdl void symtable_open(void); 189 1.1 fvdl 190 1.2 fvdl void symtable_close(void); 191 1.1 fvdl 192 1.1 fvdl symbol_t * 193 1.2 fvdl symtable_get(char *name); 194 1.1 fvdl 195 1.1 fvdl symbol_node_t * 196 1.2 fvdl symlist_search(symlist_t *symlist, char *symname); 197 1.1 fvdl 198 1.1 fvdl void 199 1.2 fvdl symlist_add(symlist_t *symlist, symbol_t *symbol, int how); 200 1.1 fvdl #define SYMLIST_INSERT_HEAD 0x00 201 1.1 fvdl #define SYMLIST_SORT 0x01 202 1.1 fvdl 203 1.2 fvdl void symlist_free(symlist_t *symlist); 204 1.1 fvdl 205 1.2 fvdl void symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1, 206 1.2 fvdl symlist_t *symlist_src2); 207 1.2 fvdl void symtable_dump(FILE *ofile, FILE *dfile); 208