File: /usr/src/linux/drivers/scsi/aic7xxx/aicasm/aicasm_symbol.h
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, this list of conditions, and the following disclaimer,
12 * without modification.
13 * 2. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * Alternatively, this software may be distributed under the terms of the
17 * GNU Public License ("GPL").
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: //depot/src/aic7xxx/aicasm/aicasm_symbol.h#4 $
32 *
33 * $FreeBSD: src/sys/dev/aic7xxx/aicasm/aicasm_symbol.h,v 1.11 2000/09/22 22:19:55 gibbs Exp $
34 */
35
36 #ifdef __linux__
37 #include "../queue.h"
38 #else
39 #include <sys/queue.h>
40 #endif
41
42 typedef enum {
43 UNINITIALIZED,
44 REGISTER,
45 ALIAS,
46 SCBLOC,
47 SRAMLOC,
48 MASK,
49 BIT,
50 CONST,
51 DOWNLOAD_CONST,
52 LABEL,
53 CONDITIONAL
54 }symtype;
55
56 typedef enum {
57 RO = 0x01,
58 WO = 0x02,
59 RW = 0x03
60 }amode_t;
61
62 struct reg_info {
63 u_int8_t address;
64 int size;
65 amode_t mode;
66 u_int8_t valid_bitmask;
67 int typecheck_masks;
68 };
69
70 typedef SLIST_HEAD(symlist, symbol_node) symlist_t;
71
72 struct mask_info {
73 symlist_t symrefs;
74 u_int8_t mask;
75 };
76
77 struct const_info {
78 u_int8_t value;
79 int define;
80 };
81
82 struct alias_info {
83 struct symbol *parent;
84 };
85
86 struct label_info {
87 int address;
88 };
89
90 struct cond_info {
91 int func_num;
92 };
93
94 typedef struct expression_info {
95 symlist_t referenced_syms;
96 int value;
97 } expression_t;
98
99 typedef struct symbol {
100 char *name;
101 symtype type;
102 union {
103 struct reg_info *rinfo;
104 struct mask_info *minfo;
105 struct const_info *cinfo;
106 struct alias_info *ainfo;
107 struct label_info *linfo;
108 struct cond_info *condinfo;
109 }info;
110 } symbol_t;
111
112 typedef struct symbol_ref {
113 symbol_t *symbol;
114 int offset;
115 } symbol_ref_t;
116
117 typedef struct symbol_node {
118 SLIST_ENTRY(symbol_node) links;
119 symbol_t *symbol;
120 } symbol_node_t;
121
122 typedef struct critical_section {
123 TAILQ_ENTRY(critical_section) links;
124 int begin_addr;
125 int end_addr;
126 } critical_section_t;
127
128 typedef enum {
129 SCOPE_ROOT,
130 SCOPE_IF,
131 SCOPE_ELSE_IF,
132 SCOPE_ELSE
133 } scope_type;
134
135 typedef struct patch_info {
136 int skip_patch;
137 int skip_instr;
138 } patch_info_t;
139
140 typedef struct scope {
141 SLIST_ENTRY(scope) scope_stack_links;
142 TAILQ_ENTRY(scope) scope_links;
143 TAILQ_HEAD(, scope) inner_scope;
144 scope_type type;
145 int inner_scope_patches;
146 int begin_addr;
147 int end_addr;
148 patch_info_t patches[2];
149 int func_num;
150 } scope_t;
151
152 TAILQ_HEAD(cs_tailq, critical_section);
153 SLIST_HEAD(scope_list, scope);
154 TAILQ_HEAD(scope_tailq, scope);
155
156 void symbol_delete __P((symbol_t *symbol));
157
158 void symtable_open __P((void));
159
160 void symtable_close __P((void));
161
162 symbol_t *
163 symtable_get __P((char *name));
164
165 symbol_node_t *
166 symlist_search __P((symlist_t *symlist, char *symname));
167
168 void
169 symlist_add __P((symlist_t *symlist, symbol_t *symbol, int how));
170 #define SYMLIST_INSERT_HEAD 0x00
171 #define SYMLIST_SORT 0x01
172
173 void symlist_free __P((symlist_t *symlist));
174
175 void symlist_merge __P((symlist_t *symlist_dest, symlist_t *symlist_src1,
176 symlist_t *symlist_src2));
177 void symtable_dump __P((FILE *ofile));
178