xref: /freebsd/sys/dev/aic7xxx/aicasm/aicasm_symbol.h (revision df7f5d4de4592a8948a25ce01e5bddfbb7ce39dc)
1 /*
2  * Aic7xxx SCSI host adapter firmware asssembler symbol table definitions
3  *
4  * Copyright (c) 1997 Justin T. Gibbs.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice immediately at the beginning of the file, without modification,
12  *    this list of conditions, and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. The name of the author may not be used to endorse or promote products
17  *    derived from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  *      $Id$
32  */
33 
34 #include <sys/queue.h>
35 
36 typedef enum {
37 	UNINITIALIZED,
38 	REGISTER,
39 	ALIAS,
40 	SCBLOC,
41 	SRAMLOC,
42 	MASK,
43 	BIT,
44 	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	value;
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 struct patch {
116         STAILQ_ENTRY(patch) links;
117 	int	  negative;
118 	int	  begin;
119         int	  end;
120 	int	  options;
121 } patch_t;
122 
123 void	symbol_delete __P((symbol_t *symbol));
124 
125 void	symtable_open __P((void));
126 
127 void	symtable_close __P((void));
128 
129 symbol_t *
130 	symtable_get __P((char *name));
131 
132 symbol_node_t *
133 	symlist_search __P((symlist_t *symlist, char *symname));
134 
135 void
136 	symlist_add __P((symlist_t *symlist, symbol_t *symbol, int how));
137 #define SYMLIST_INSERT_HEAD	0x00
138 #define SYMLIST_SORT		0x01
139 
140 void	symlist_free __P((symlist_t *symlist));
141 
142 void	symlist_merge __P((symlist_t *symlist_dest, symlist_t *symlist_src1,
143 			   symlist_t *symlist_src2));
144 void	symtable_dump __P((FILE *ofile));
145