Home | History | Annotate | Line # | Download | only in aic7xxx
aicasm_symbol.h revision 1.1
      1 /*	$NetBSD: aicasm_symbol.h,v 1.1 2000/03/15 02:09:15 fvdl Exp $	*/
      2 
      3 /*
      4  * Aic7xxx SCSI host adapter firmware asssembler symbol table definitions
      5  *
      6  * Copyright (c) 1997 Justin T. Gibbs.
      7  * All rights reserved.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions, and the following disclaimer,
     14  *    without modification.
     15  * 2. The name of the author may not be used to endorse or promote products
     16  *    derived from this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
     22  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28  * SUCH DAMAGE.
     29  *
     30  * $FreeBSD: src/sys/dev/aic7xxx/aicasm_symbol.h,v 1.6 1999/12/06 18:23:31 gibbs Exp $
     31  */
     32 
     33 #include <sys/queue.h>
     34 
     35 typedef enum {
     36 	UNINITIALIZED,
     37 	REGISTER,
     38 	ALIAS,
     39 	SCBLOC,
     40 	SRAMLOC,
     41 	MASK,
     42 	BIT,
     43 	CONST,
     44 	DOWNLOAD_CONST,
     45 	LABEL,
     46 	CONDITIONAL
     47 }symtype;
     48 
     49 typedef enum {
     50 	RO = 0x01,
     51 	WO = 0x02,
     52 	RW = 0x03
     53 }amode_t;
     54 
     55 struct reg_info {
     56 	u_int8_t address;
     57 	int	 size;
     58 	amode_t	 mode;
     59 	u_int8_t valid_bitmask;
     60 	int	 typecheck_masks;
     61 };
     62 
     63 typedef SLIST_HEAD(symlist, symbol_node) symlist_t;
     64 
     65 struct mask_info {
     66 	symlist_t symrefs;
     67 	u_int8_t mask;
     68 };
     69 
     70 struct const_info {
     71 	u_int8_t value;
     72 	int	 define;
     73 };
     74 
     75 struct alias_info {
     76 	struct symbol *parent;
     77 };
     78 
     79 struct label_info {
     80 	int	address;
     81 };
     82 
     83 struct cond_info {
     84 	int	func_num;
     85 };
     86 
     87 typedef struct expression_info {
     88         symlist_t       referenced_syms;
     89         int             value;
     90 } expression_t;
     91 
     92 typedef struct symbol {
     93 	char	*name;
     94 	symtype	type;
     95 	union	{
     96 		struct reg_info *rinfo;
     97 		struct mask_info *minfo;
     98 		struct const_info *cinfo;
     99 		struct alias_info *ainfo;
    100 		struct label_info *linfo;
    101 		struct cond_info *condinfo;
    102 	}info;
    103 } symbol_t;
    104 
    105 typedef struct symbol_ref {
    106 	symbol_t *symbol;
    107 	int	 offset;
    108 } symbol_ref_t;
    109 
    110 typedef struct symbol_node {
    111 	SLIST_ENTRY(symbol_node) links;
    112 	symbol_t *symbol;
    113 }symbol_node_t;
    114 
    115 typedef enum {
    116 	SCOPE_ROOT,
    117 	SCOPE_IF,
    118 	SCOPE_ELSE_IF,
    119 	SCOPE_ELSE
    120 } scope_type;
    121 
    122 typedef struct patch_info {
    123 	int skip_patch;
    124 	int skip_instr;
    125 } patch_info_t;
    126 
    127 typedef struct scope {
    128 	SLIST_ENTRY(scope) scope_stack_links;
    129 	TAILQ_ENTRY(scope) scope_links;
    130 	TAILQ_HEAD(, scope) inner_scope;
    131 	scope_type type;
    132 	int inner_scope_patches;
    133 	int begin_addr;
    134         int end_addr;
    135 	patch_info_t patches[2];
    136 	int func_num;
    137 } scope_t;
    138 
    139 SLIST_HEAD(scope_list, scope);
    140 TAILQ_HEAD(scope_tailq, scope);
    141 
    142 void	symbol_delete __P((symbol_t *symbol));
    143 
    144 void	symtable_open __P((void));
    145 
    146 void	symtable_close __P((void));
    147 
    148 symbol_t *
    149 	symtable_get __P((char *name));
    150 
    151 symbol_node_t *
    152 	symlist_search __P((symlist_t *symlist, char *symname));
    153 
    154 void
    155 	symlist_add __P((symlist_t *symlist, symbol_t *symbol, int how));
    156 #define SYMLIST_INSERT_HEAD	0x00
    157 #define SYMLIST_SORT		0x01
    158 
    159 void	symlist_free __P((symlist_t *symlist));
    160 
    161 void	symlist_merge __P((symlist_t *symlist_dest, symlist_t *symlist_src1,
    162 			   symlist_t *symlist_src2));
    163 void	symtable_dump __P((FILE *ofile));
    164