18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Aic7xxx SCSI host adapter firmware assembler symbol table definitions 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (c) 1997 Justin T. Gibbs. 58c2ecf20Sopenharmony_ci * Copyright (c) 2002 Adaptec Inc. 68c2ecf20Sopenharmony_ci * All rights reserved. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 98c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions 108c2ecf20Sopenharmony_ci * are met: 118c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright 128c2ecf20Sopenharmony_ci * notice, this list of conditions, and the following disclaimer, 138c2ecf20Sopenharmony_ci * without modification. 148c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce at minimum a disclaimer 158c2ecf20Sopenharmony_ci * substantially similar to the "NO WARRANTY" disclaimer below 168c2ecf20Sopenharmony_ci * ("Disclaimer") and any redistribution must be conditioned upon 178c2ecf20Sopenharmony_ci * including a substantially similar Disclaimer requirement for further 188c2ecf20Sopenharmony_ci * binary redistribution. 198c2ecf20Sopenharmony_ci * 3. Neither the names of the above-listed copyright holders nor the names 208c2ecf20Sopenharmony_ci * of any contributors may be used to endorse or promote products derived 218c2ecf20Sopenharmony_ci * from this software without specific prior written permission. 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the 248c2ecf20Sopenharmony_ci * GNU General Public License ("GPL") version 2 as published by the Free 258c2ecf20Sopenharmony_ci * Software Foundation. 268c2ecf20Sopenharmony_ci * 278c2ecf20Sopenharmony_ci * NO WARRANTY 288c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 298c2ecf20Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 308c2ecf20Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 318c2ecf20Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 328c2ecf20Sopenharmony_ci * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 338c2ecf20Sopenharmony_ci * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 348c2ecf20Sopenharmony_ci * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 358c2ecf20Sopenharmony_ci * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 368c2ecf20Sopenharmony_ci * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 378c2ecf20Sopenharmony_ci * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 388c2ecf20Sopenharmony_ci * POSSIBILITY OF SUCH DAMAGES. 398c2ecf20Sopenharmony_ci * 408c2ecf20Sopenharmony_ci * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#17 $ 418c2ecf20Sopenharmony_ci * 428c2ecf20Sopenharmony_ci * $FreeBSD$ 438c2ecf20Sopenharmony_ci */ 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#include "../queue.h" 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_citypedef enum { 488c2ecf20Sopenharmony_ci UNINITIALIZED, 498c2ecf20Sopenharmony_ci REGISTER, 508c2ecf20Sopenharmony_ci ALIAS, 518c2ecf20Sopenharmony_ci SCBLOC, 528c2ecf20Sopenharmony_ci SRAMLOC, 538c2ecf20Sopenharmony_ci ENUM_ENTRY, 548c2ecf20Sopenharmony_ci FIELD, 558c2ecf20Sopenharmony_ci MASK, 568c2ecf20Sopenharmony_ci ENUM, 578c2ecf20Sopenharmony_ci CONST, 588c2ecf20Sopenharmony_ci DOWNLOAD_CONST, 598c2ecf20Sopenharmony_ci LABEL, 608c2ecf20Sopenharmony_ci CONDITIONAL, 618c2ecf20Sopenharmony_ci MACRO 628c2ecf20Sopenharmony_ci} symtype; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_citypedef enum { 658c2ecf20Sopenharmony_ci RO = 0x01, 668c2ecf20Sopenharmony_ci WO = 0x02, 678c2ecf20Sopenharmony_ci RW = 0x03 688c2ecf20Sopenharmony_ci}amode_t; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_citypedef SLIST_HEAD(symlist, symbol_node) symlist_t; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_cistruct reg_info { 738c2ecf20Sopenharmony_ci u_int address; 748c2ecf20Sopenharmony_ci int size; 758c2ecf20Sopenharmony_ci amode_t mode; 768c2ecf20Sopenharmony_ci symlist_t fields; 778c2ecf20Sopenharmony_ci uint8_t valid_bitmask; 788c2ecf20Sopenharmony_ci uint8_t modes; 798c2ecf20Sopenharmony_ci int typecheck_masks; 808c2ecf20Sopenharmony_ci}; 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_cistruct field_info { 838c2ecf20Sopenharmony_ci symlist_t symrefs; 848c2ecf20Sopenharmony_ci uint8_t value; 858c2ecf20Sopenharmony_ci uint8_t mask; 868c2ecf20Sopenharmony_ci}; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_cistruct const_info { 898c2ecf20Sopenharmony_ci u_int value; 908c2ecf20Sopenharmony_ci int define; 918c2ecf20Sopenharmony_ci}; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_cistruct alias_info { 948c2ecf20Sopenharmony_ci struct symbol *parent; 958c2ecf20Sopenharmony_ci}; 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_cistruct label_info { 988c2ecf20Sopenharmony_ci int address; 998c2ecf20Sopenharmony_ci int exported; 1008c2ecf20Sopenharmony_ci}; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_cistruct cond_info { 1038c2ecf20Sopenharmony_ci int func_num; 1048c2ecf20Sopenharmony_ci}; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_cistruct macro_arg { 1078c2ecf20Sopenharmony_ci STAILQ_ENTRY(macro_arg) links; 1088c2ecf20Sopenharmony_ci regex_t arg_regex; 1098c2ecf20Sopenharmony_ci char *replacement_text; 1108c2ecf20Sopenharmony_ci}; 1118c2ecf20Sopenharmony_ciSTAILQ_HEAD(macro_arg_list, macro_arg) args; 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_cistruct macro_info { 1148c2ecf20Sopenharmony_ci struct macro_arg_list args; 1158c2ecf20Sopenharmony_ci int narg; 1168c2ecf20Sopenharmony_ci const char* body; 1178c2ecf20Sopenharmony_ci}; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_citypedef struct expression_info { 1208c2ecf20Sopenharmony_ci symlist_t referenced_syms; 1218c2ecf20Sopenharmony_ci int value; 1228c2ecf20Sopenharmony_ci} expression_t; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_citypedef struct symbol { 1258c2ecf20Sopenharmony_ci char *name; 1268c2ecf20Sopenharmony_ci symtype type; 1278c2ecf20Sopenharmony_ci int count; 1288c2ecf20Sopenharmony_ci union { 1298c2ecf20Sopenharmony_ci struct reg_info *rinfo; 1308c2ecf20Sopenharmony_ci struct field_info *finfo; 1318c2ecf20Sopenharmony_ci struct const_info *cinfo; 1328c2ecf20Sopenharmony_ci struct alias_info *ainfo; 1338c2ecf20Sopenharmony_ci struct label_info *linfo; 1348c2ecf20Sopenharmony_ci struct cond_info *condinfo; 1358c2ecf20Sopenharmony_ci struct macro_info *macroinfo; 1368c2ecf20Sopenharmony_ci } info; 1378c2ecf20Sopenharmony_ci int dont_generate_debug_code; 1388c2ecf20Sopenharmony_ci} symbol_t; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_citypedef struct symbol_ref { 1418c2ecf20Sopenharmony_ci symbol_t *symbol; 1428c2ecf20Sopenharmony_ci int offset; 1438c2ecf20Sopenharmony_ci} symbol_ref_t; 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_citypedef struct symbol_node { 1468c2ecf20Sopenharmony_ci SLIST_ENTRY(symbol_node) links; 1478c2ecf20Sopenharmony_ci symbol_t *symbol; 1488c2ecf20Sopenharmony_ci} symbol_node_t; 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_citypedef struct critical_section { 1518c2ecf20Sopenharmony_ci TAILQ_ENTRY(critical_section) links; 1528c2ecf20Sopenharmony_ci int begin_addr; 1538c2ecf20Sopenharmony_ci int end_addr; 1548c2ecf20Sopenharmony_ci} critical_section_t; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_citypedef enum { 1578c2ecf20Sopenharmony_ci SCOPE_ROOT, 1588c2ecf20Sopenharmony_ci SCOPE_IF, 1598c2ecf20Sopenharmony_ci SCOPE_ELSE_IF, 1608c2ecf20Sopenharmony_ci SCOPE_ELSE 1618c2ecf20Sopenharmony_ci} scope_type; 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_citypedef struct patch_info { 1648c2ecf20Sopenharmony_ci int skip_patch; 1658c2ecf20Sopenharmony_ci int skip_instr; 1668c2ecf20Sopenharmony_ci} patch_info_t; 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_citypedef struct scope { 1698c2ecf20Sopenharmony_ci SLIST_ENTRY(scope) scope_stack_links; 1708c2ecf20Sopenharmony_ci TAILQ_ENTRY(scope) scope_links; 1718c2ecf20Sopenharmony_ci TAILQ_HEAD(, scope) inner_scope; 1728c2ecf20Sopenharmony_ci scope_type type; 1738c2ecf20Sopenharmony_ci int inner_scope_patches; 1748c2ecf20Sopenharmony_ci int begin_addr; 1758c2ecf20Sopenharmony_ci int end_addr; 1768c2ecf20Sopenharmony_ci patch_info_t patches[2]; 1778c2ecf20Sopenharmony_ci int func_num; 1788c2ecf20Sopenharmony_ci} scope_t; 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ciTAILQ_HEAD(cs_tailq, critical_section); 1818c2ecf20Sopenharmony_ciSLIST_HEAD(scope_list, scope); 1828c2ecf20Sopenharmony_ciTAILQ_HEAD(scope_tailq, scope); 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_civoid symbol_delete(symbol_t *symbol); 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_civoid symtable_open(void); 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_civoid symtable_close(void); 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_cisymbol_t * 1918c2ecf20Sopenharmony_ci symtable_get(char *name); 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_cisymbol_node_t * 1948c2ecf20Sopenharmony_ci symlist_search(symlist_t *symlist, char *symname); 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_civoid 1978c2ecf20Sopenharmony_ci symlist_add(symlist_t *symlist, symbol_t *symbol, int how); 1988c2ecf20Sopenharmony_ci#define SYMLIST_INSERT_HEAD 0x00 1998c2ecf20Sopenharmony_ci#define SYMLIST_SORT 0x01 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_civoid symlist_free(symlist_t *symlist); 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_civoid symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1, 2048c2ecf20Sopenharmony_ci symlist_t *symlist_src2); 2058c2ecf20Sopenharmony_civoid symtable_dump(FILE *ofile, FILE *dfile); 206