Path: blob/main/sys/dev/aic7xxx/aicasm/aicasm_symbol.h
39566 views
/*-1* Aic7xxx SCSI host adapter firmware asssembler symbol table definitions2*3* SPDX-License-Identifier: BSD-3-Clause4*5* Copyright (c) 1997 Justin T. Gibbs.6* Copyright (c) 2002 Adaptec Inc.7* All rights reserved.8*9* Redistribution and use in source and binary forms, with or without10* modification, are permitted provided that the following conditions11* are met:12* 1. Redistributions of source code must retain the above copyright13* notice, this list of conditions, and the following disclaimer,14* without modification.15* 2. Redistributions in binary form must reproduce at minimum a disclaimer16* substantially similar to the "NO WARRANTY" disclaimer below17* ("Disclaimer") and any redistribution must be conditioned upon18* including a substantially similar Disclaimer requirement for further19* binary redistribution.20* 3. Neither the names of the above-listed copyright holders nor the names21* of any contributors may be used to endorse or promote products derived22* from this software without specific prior written permission.23*24* Alternatively, this software may be distributed under the terms of the25* GNU General Public License ("GPL") version 2 as published by the Free26* Software Foundation.27*28* NO WARRANTY29* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS30* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT31* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR32* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT33* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL34* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS35* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)36* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,37* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING38* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE39* POSSIBILITY OF SUCH DAMAGES.40*41* $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#17 $42*/4344#include <sys/queue.h>4546typedef enum {47UNINITIALIZED,48REGISTER,49ALIAS,50SCBLOC,51SRAMLOC,52ENUM_ENTRY,53FIELD,54MASK,55ENUM,56CONST,57DOWNLOAD_CONST,58LABEL,59CONDITIONAL,60MACRO61} symtype;6263typedef enum {64RO = 0x01,65WO = 0x02,66RW = 0x0367}amode_t;6869typedef SLIST_HEAD(symlist, symbol_node) symlist_t;7071struct reg_info {72u_int address;73int size;74amode_t mode;75symlist_t fields;76uint8_t valid_bitmask;77uint8_t modes;78int typecheck_masks;79};8081struct field_info {82symlist_t symrefs;83uint8_t value;84uint8_t mask;85};8687struct const_info {88u_int value;89int define;90};9192struct alias_info {93struct symbol *parent;94};9596struct label_info {97int address;98int exported;99};100101struct cond_info {102int func_num;103};104105struct macro_arg {106STAILQ_ENTRY(macro_arg) links;107regex_t arg_regex;108char *replacement_text;109};110STAILQ_HEAD(macro_arg_list, macro_arg);111112struct macro_info {113struct macro_arg_list args;114int narg;115const char* body;116};117118typedef struct expression_info {119symlist_t referenced_syms;120int value;121} expression_t;122123typedef struct symbol {124char *name;125symtype type;126union {127struct reg_info *rinfo;128struct field_info *finfo;129struct const_info *cinfo;130struct alias_info *ainfo;131struct label_info *linfo;132struct cond_info *condinfo;133struct macro_info *macroinfo;134}info;135} symbol_t;136137typedef struct symbol_ref {138symbol_t *symbol;139int offset;140} symbol_ref_t;141142typedef struct symbol_node {143SLIST_ENTRY(symbol_node) links;144symbol_t *symbol;145} symbol_node_t;146147typedef struct critical_section {148TAILQ_ENTRY(critical_section) links;149int begin_addr;150int end_addr;151} critical_section_t;152153typedef enum {154SCOPE_ROOT,155SCOPE_IF,156SCOPE_ELSE_IF,157SCOPE_ELSE158} scope_type;159160typedef struct patch_info {161int skip_patch;162int skip_instr;163} patch_info_t;164165typedef struct scope {166SLIST_ENTRY(scope) scope_stack_links;167TAILQ_ENTRY(scope) scope_links;168TAILQ_HEAD(, scope) inner_scope;169scope_type type;170int inner_scope_patches;171int begin_addr;172int end_addr;173patch_info_t patches[2];174int func_num;175} scope_t;176177TAILQ_HEAD(cs_tailq, critical_section);178SLIST_HEAD(scope_list, scope);179TAILQ_HEAD(scope_tailq, scope);180181void symbol_delete(symbol_t *symbol);182183void symtable_open(void);184185void symtable_close(void);186187symbol_t *188symtable_get(const char *name);189190symbol_node_t *191symlist_search(symlist_t *symlist, char *symname);192193void194symlist_add(symlist_t *symlist, symbol_t *symbol, int how);195#define SYMLIST_INSERT_HEAD 0x00196#define SYMLIST_SORT 0x01197198void symlist_free(symlist_t *symlist);199200void symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1,201symlist_t *symlist_src2);202void symtable_dump(FILE *ofile, FILE *dfile);203204205