aicasm_symbol.h revision 65943
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 * Alternatively, this software may be distributed under the terms of the 17 * GNU Public License ("GPL"). 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * $Id$ 32 * 33 * $FreeBSD: head/sys/dev/aic7xxx/aicasm/aicasm_symbol.h 65943 2000-09-16 20:02:39Z gibbs $ 34 */ 35 36#ifdef __linux__ 37#include "../queue.h" 38#else 39#include <sys/queue.h> 40#endif 41 42typedef enum { 43 UNINITIALIZED, 44 REGISTER, 45 ALIAS, 46 SCBLOC, 47 SRAMLOC, 48 MASK, 49 BIT, 50 CONST, 51 DOWNLOAD_CONST, 52 LABEL, 53 CONDITIONAL 54}symtype; 55 56typedef enum { 57 RO = 0x01, 58 WO = 0x02, 59 RW = 0x03 60}amode_t; 61 62struct reg_info { 63 u_int8_t address; 64 int size; 65 amode_t mode; 66 u_int8_t valid_bitmask; 67 int typecheck_masks; 68}; 69 70typedef SLIST_HEAD(symlist, symbol_node) symlist_t; 71 72struct mask_info { 73 symlist_t symrefs; 74 u_int8_t mask; 75}; 76 77struct const_info { 78 u_int8_t value; 79 int define; 80}; 81 82struct alias_info { 83 struct symbol *parent; 84}; 85 86struct label_info { 87 int address; 88}; 89 90struct cond_info { 91 int func_num; 92}; 93 94typedef struct expression_info { 95 symlist_t referenced_syms; 96 int value; 97} expression_t; 98 99typedef struct symbol { 100 char *name; 101 symtype type; 102 union { 103 struct reg_info *rinfo; 104 struct mask_info *minfo; 105 struct const_info *cinfo; 106 struct alias_info *ainfo; 107 struct label_info *linfo; 108 struct cond_info *condinfo; 109 }info; 110} symbol_t; 111 112typedef struct symbol_ref { 113 symbol_t *symbol; 114 int offset; 115} symbol_ref_t; 116 117typedef struct symbol_node { 118 SLIST_ENTRY(symbol_node) links; 119 symbol_t *symbol; 120}symbol_node_t; 121 122typedef enum { 123 SCOPE_ROOT, 124 SCOPE_IF, 125 SCOPE_ELSE_IF, 126 SCOPE_ELSE 127} scope_type; 128 129typedef struct patch_info { 130 int skip_patch; 131 int skip_instr; 132} patch_info_t; 133 134typedef struct scope { 135 SLIST_ENTRY(scope) scope_stack_links; 136 TAILQ_ENTRY(scope) scope_links; 137 TAILQ_HEAD(, scope) inner_scope; 138 scope_type type; 139 int inner_scope_patches; 140 int begin_addr; 141 int end_addr; 142 patch_info_t patches[2]; 143 int func_num; 144} scope_t; 145 146SLIST_HEAD(scope_list, scope); 147TAILQ_HEAD(scope_tailq, scope); 148 149void symbol_delete __P((symbol_t *symbol)); 150 151void symtable_open __P((void)); 152 153void symtable_close __P((void)); 154 155symbol_t * 156 symtable_get __P((char *name)); 157 158symbol_node_t * 159 symlist_search __P((symlist_t *symlist, char *symname)); 160 161void 162 symlist_add __P((symlist_t *symlist, symbol_t *symbol, int how)); 163#define SYMLIST_INSERT_HEAD 0x00 164#define SYMLIST_SORT 0x01 165 166void symlist_free __P((symlist_t *symlist)); 167 168void symlist_merge __P((symlist_t *symlist_dest, symlist_t *symlist_src1, 169 symlist_t *symlist_src2)); 170void symtable_dump __P((FILE *ofile)); 171