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