aicasm_symbol.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * Aic7xxx SCSI host adapter firmware assembler symbol table definitions
  3. *
  4. * Copyright (c) 1997 Justin T. Gibbs.
  5. * Copyright (c) 2002 Adaptec Inc.
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions, and the following disclaimer,
  13. * without modification.
  14. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  15. * substantially similar to the "NO WARRANTY" disclaimer below
  16. * ("Disclaimer") and any redistribution must be conditioned upon
  17. * including a substantially similar Disclaimer requirement for further
  18. * binary redistribution.
  19. * 3. Neither the names of the above-listed copyright holders nor the names
  20. * of any contributors may be used to endorse or promote products derived
  21. * from this software without specific prior written permission.
  22. *
  23. * Alternatively, this software may be distributed under the terms of the
  24. * GNU General Public License ("GPL") version 2 as published by the Free
  25. * Software Foundation.
  26. *
  27. * NO WARRANTY
  28. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  29. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  30. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  31. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  32. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  34. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  36. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  37. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  38. * POSSIBILITY OF SUCH DAMAGES.
  39. *
  40. * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_symbol.h#17 $
  41. *
  42. * $FreeBSD$
  43. */
  44. #include "../queue.h"
  45. typedef enum {
  46. UNINITIALIZED,
  47. REGISTER,
  48. ALIAS,
  49. SCBLOC,
  50. SRAMLOC,
  51. ENUM_ENTRY,
  52. FIELD,
  53. MASK,
  54. ENUM,
  55. CONST,
  56. DOWNLOAD_CONST,
  57. LABEL,
  58. CONDITIONAL,
  59. MACRO
  60. } symtype;
  61. typedef enum {
  62. RO = 0x01,
  63. WO = 0x02,
  64. RW = 0x03
  65. }amode_t;
  66. typedef SLIST_HEAD(symlist, symbol_node) symlist_t;
  67. struct reg_info {
  68. u_int address;
  69. int size;
  70. amode_t mode;
  71. symlist_t fields;
  72. uint8_t valid_bitmask;
  73. uint8_t modes;
  74. int typecheck_masks;
  75. };
  76. struct field_info {
  77. symlist_t symrefs;
  78. uint8_t value;
  79. uint8_t mask;
  80. };
  81. struct const_info {
  82. u_int value;
  83. int define;
  84. };
  85. struct alias_info {
  86. struct symbol *parent;
  87. };
  88. struct label_info {
  89. int address;
  90. int exported;
  91. };
  92. struct cond_info {
  93. int func_num;
  94. };
  95. struct macro_arg {
  96. STAILQ_ENTRY(macro_arg) links;
  97. regex_t arg_regex;
  98. char *replacement_text;
  99. };
  100. STAILQ_HEAD(macro_arg_list, macro_arg);
  101. struct macro_info {
  102. struct macro_arg_list args;
  103. int narg;
  104. const char* body;
  105. };
  106. typedef struct expression_info {
  107. symlist_t referenced_syms;
  108. int value;
  109. } expression_t;
  110. typedef struct symbol {
  111. char *name;
  112. symtype type;
  113. int count;
  114. union {
  115. struct reg_info *rinfo;
  116. struct field_info *finfo;
  117. struct const_info *cinfo;
  118. struct alias_info *ainfo;
  119. struct label_info *linfo;
  120. struct cond_info *condinfo;
  121. struct macro_info *macroinfo;
  122. } info;
  123. int dont_generate_debug_code;
  124. } symbol_t;
  125. typedef struct symbol_ref {
  126. symbol_t *symbol;
  127. int offset;
  128. } symbol_ref_t;
  129. typedef struct symbol_node {
  130. SLIST_ENTRY(symbol_node) links;
  131. symbol_t *symbol;
  132. } symbol_node_t;
  133. typedef struct critical_section {
  134. TAILQ_ENTRY(critical_section) links;
  135. int begin_addr;
  136. int end_addr;
  137. } critical_section_t;
  138. typedef enum {
  139. SCOPE_ROOT,
  140. SCOPE_IF,
  141. SCOPE_ELSE_IF,
  142. SCOPE_ELSE
  143. } scope_type;
  144. typedef struct patch_info {
  145. int skip_patch;
  146. int skip_instr;
  147. } patch_info_t;
  148. typedef struct scope {
  149. SLIST_ENTRY(scope) scope_stack_links;
  150. TAILQ_ENTRY(scope) scope_links;
  151. TAILQ_HEAD(, scope) inner_scope;
  152. scope_type type;
  153. int inner_scope_patches;
  154. int begin_addr;
  155. int end_addr;
  156. patch_info_t patches[2];
  157. int func_num;
  158. } scope_t;
  159. TAILQ_HEAD(cs_tailq, critical_section);
  160. SLIST_HEAD(scope_list, scope);
  161. TAILQ_HEAD(scope_tailq, scope);
  162. void symbol_delete(symbol_t *symbol);
  163. void symtable_open(void);
  164. void symtable_close(void);
  165. symbol_t *
  166. symtable_get(char *name);
  167. symbol_node_t *
  168. symlist_search(symlist_t *symlist, char *symname);
  169. void
  170. symlist_add(symlist_t *symlist, symbol_t *symbol, int how);
  171. #define SYMLIST_INSERT_HEAD 0x00
  172. #define SYMLIST_SORT 0x01
  173. void symlist_free(symlist_t *symlist);
  174. void symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1,
  175. symlist_t *symlist_src2);
  176. void symtable_dump(FILE *ofile, FILE *dfile);