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