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