Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Aic7xxx SCSI host adapter firmware assembler symbol table definitions
0003  *
0004  * Copyright (c) 1997 Justin T. Gibbs.
0005  * Copyright (c) 2002 Adaptec Inc.
0006  * All rights reserved.
0007  *
0008  * Redistribution and use in source and binary forms, with or without
0009  * modification, are permitted provided that the following conditions
0010  * are met:
0011  * 1. Redistributions of source code must retain the above copyright
0012  *    notice, this list of conditions, and the following disclaimer,
0013  *    without modification.
0014  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
0015  *    substantially similar to the "NO WARRANTY" disclaimer below
0016  *    ("Disclaimer") and any redistribution must be conditioned upon
0017  *    including a substantially similar Disclaimer requirement for further
0018  *    binary redistribution.
0019  * 3. Neither the names of the above-listed copyright holders nor the names
0020  *    of any contributors may be used to endorse or promote products derived
0021  *    from this software without specific prior written permission.
0022  *
0023  * Alternatively, this software may be distributed under the terms of the
0024  * GNU General Public License ("GPL") version 2 as published by the Free
0025  * Software Foundation.
0026  *
0027  * NO WARRANTY
0028  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0029  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0030  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
0031  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0032  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0033  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
0034  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0035  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
0036  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
0037  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0038  * POSSIBILITY OF SUCH DAMAGES.
0039  *
0040  * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#17 $
0041  *
0042  * $FreeBSD$
0043  */
0044 
0045 #include "../queue.h"
0046 
0047 typedef enum {
0048     UNINITIALIZED,
0049     REGISTER,
0050     ALIAS,
0051     SCBLOC,
0052     SRAMLOC,
0053     ENUM_ENTRY,
0054     FIELD,
0055     MASK,
0056     ENUM,
0057     CONST,
0058     DOWNLOAD_CONST,
0059     LABEL,
0060     CONDITIONAL,
0061     MACRO
0062 } symtype;
0063 
0064 typedef enum {
0065     RO = 0x01,
0066     WO = 0x02,
0067     RW = 0x03
0068 }amode_t;
0069 
0070 typedef SLIST_HEAD(symlist, symbol_node) symlist_t;
0071 
0072 struct reg_info {
0073     u_int     address;
0074     int   size;
0075     amode_t   mode;
0076     symlist_t fields;
0077     uint8_t   valid_bitmask;
0078     uint8_t   modes;
0079     int   typecheck_masks;
0080 };
0081 
0082 struct field_info {
0083     symlist_t symrefs;
0084     uint8_t   value;
0085     uint8_t   mask;
0086 };
0087 
0088 struct const_info {
0089     u_int   value;
0090     int define;
0091 };
0092 
0093 struct alias_info {
0094     struct symbol *parent;
0095 };
0096 
0097 struct label_info {
0098     int address;
0099     int exported;
0100 };
0101 
0102 struct cond_info {
0103     int func_num;
0104 };
0105 
0106 struct macro_arg {
0107     STAILQ_ENTRY(macro_arg) links;
0108     regex_t arg_regex;
0109     char   *replacement_text;
0110 };
0111 STAILQ_HEAD(macro_arg_list, macro_arg);
0112 
0113 struct macro_info {
0114     struct macro_arg_list args;
0115     int   narg;
0116     const char* body;
0117 };
0118 
0119 typedef struct expression_info {
0120         symlist_t       referenced_syms;
0121         int             value;
0122 } expression_t;
0123 
0124 typedef struct symbol {
0125     char    *name;
0126     symtype type;
0127     int count;
0128     union   {
0129         struct reg_info   *rinfo;
0130         struct field_info *finfo;
0131         struct const_info *cinfo;
0132         struct alias_info *ainfo;
0133         struct label_info *linfo;
0134         struct cond_info  *condinfo;
0135         struct macro_info *macroinfo;
0136     } info;
0137     int dont_generate_debug_code;
0138 } symbol_t;
0139 
0140 typedef struct symbol_ref {
0141     symbol_t *symbol;
0142     int  offset;
0143 } symbol_ref_t;
0144 
0145 typedef struct symbol_node {
0146     SLIST_ENTRY(symbol_node) links;
0147     symbol_t *symbol;
0148 } symbol_node_t;
0149 
0150 typedef struct critical_section {
0151     TAILQ_ENTRY(critical_section) links;
0152     int begin_addr;
0153     int end_addr;
0154 } critical_section_t;
0155 
0156 typedef enum {
0157     SCOPE_ROOT,
0158     SCOPE_IF,
0159     SCOPE_ELSE_IF,
0160     SCOPE_ELSE
0161 } scope_type;
0162 
0163 typedef struct patch_info {
0164     int skip_patch;
0165     int skip_instr;
0166 } patch_info_t;
0167 
0168 typedef struct scope {
0169     SLIST_ENTRY(scope) scope_stack_links;
0170     TAILQ_ENTRY(scope) scope_links;
0171     TAILQ_HEAD(, scope) inner_scope;
0172     scope_type type;
0173     int inner_scope_patches;
0174     int begin_addr;
0175         int end_addr;
0176     patch_info_t patches[2];
0177     int func_num;
0178 } scope_t;
0179 
0180 TAILQ_HEAD(cs_tailq, critical_section);
0181 SLIST_HEAD(scope_list, scope);
0182 TAILQ_HEAD(scope_tailq, scope);
0183 
0184 void    symbol_delete(symbol_t *symbol);
0185 
0186 void    symtable_open(void);
0187 
0188 void    symtable_close(void);
0189 
0190 symbol_t *
0191     symtable_get(char *name);
0192 
0193 symbol_node_t *
0194     symlist_search(symlist_t *symlist, char *symname);
0195 
0196 void
0197     symlist_add(symlist_t *symlist, symbol_t *symbol, int how);
0198 #define SYMLIST_INSERT_HEAD 0x00
0199 #define SYMLIST_SORT        0x01
0200 
0201 void    symlist_free(symlist_t *symlist);
0202 
0203 void    symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1,
0204               symlist_t *symlist_src2);
0205 void    symtable_dump(FILE *ofile, FILE *dfile);