aicasm_symbol.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. * Aic7xxx SCSI host adapter firmware asssembler 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. #ifdef __linux__
  45. #include "../queue.h"
  46. #else
  47. #include <sys/queue.h>
  48. #endif
  49. typedef enum {
  50. UNINITIALIZED,
  51. REGISTER,
  52. ALIAS,
  53. SCBLOC,
  54. SRAMLOC,
  55. ENUM_ENTRY,
  56. FIELD,
  57. MASK,
  58. ENUM,
  59. CONST,
  60. DOWNLOAD_CONST,
  61. LABEL,
  62. CONDITIONAL,
  63. MACRO
  64. } symtype;
  65. typedef enum {
  66. RO = 0x01,
  67. WO = 0x02,
  68. RW = 0x03
  69. }amode_t;
  70. typedef SLIST_HEAD(symlist, symbol_node) symlist_t;
  71. struct reg_info {
  72. u_int address;
  73. int size;
  74. amode_t mode;
  75. symlist_t fields;
  76. uint8_t valid_bitmask;
  77. uint8_t modes;
  78. int typecheck_masks;
  79. };
  80. struct field_info {
  81. symlist_t symrefs;
  82. uint8_t value;
  83. uint8_t mask;
  84. };
  85. struct const_info {
  86. u_int value;
  87. int define;
  88. };
  89. struct alias_info {
  90. struct symbol *parent;
  91. };
  92. struct label_info {
  93. int address;
  94. int exported;
  95. };
  96. struct cond_info {
  97. int func_num;
  98. };
  99. struct macro_arg {
  100. STAILQ_ENTRY(macro_arg) links;
  101. regex_t arg_regex;
  102. char *replacement_text;
  103. };
  104. STAILQ_HEAD(macro_arg_list, macro_arg) args;
  105. struct macro_info {
  106. struct macro_arg_list args;
  107. int narg;
  108. const char* body;
  109. };
  110. typedef struct expression_info {
  111. symlist_t referenced_syms;
  112. int value;
  113. } expression_t;
  114. typedef struct symbol {
  115. char *name;
  116. symtype type;
  117. union {
  118. struct reg_info *rinfo;
  119. struct field_info *finfo;
  120. struct const_info *cinfo;
  121. struct alias_info *ainfo;
  122. struct label_info *linfo;
  123. struct cond_info *condinfo;
  124. struct macro_info *macroinfo;
  125. }info;
  126. } symbol_t;
  127. typedef struct symbol_ref {
  128. symbol_t *symbol;
  129. int offset;
  130. } symbol_ref_t;
  131. typedef struct symbol_node {
  132. SLIST_ENTRY(symbol_node) links;
  133. symbol_t *symbol;
  134. } symbol_node_t;
  135. typedef struct critical_section {
  136. TAILQ_ENTRY(critical_section) links;
  137. int begin_addr;
  138. int end_addr;
  139. } critical_section_t;
  140. typedef enum {
  141. SCOPE_ROOT,
  142. SCOPE_IF,
  143. SCOPE_ELSE_IF,
  144. SCOPE_ELSE
  145. } scope_type;
  146. typedef struct patch_info {
  147. int skip_patch;
  148. int skip_instr;
  149. } patch_info_t;
  150. typedef struct scope {
  151. SLIST_ENTRY(scope) scope_stack_links;
  152. TAILQ_ENTRY(scope) scope_links;
  153. TAILQ_HEAD(, scope) inner_scope;
  154. scope_type type;
  155. int inner_scope_patches;
  156. int begin_addr;
  157. int end_addr;
  158. patch_info_t patches[2];
  159. int func_num;
  160. } scope_t;
  161. TAILQ_HEAD(cs_tailq, critical_section);
  162. SLIST_HEAD(scope_list, scope);
  163. TAILQ_HEAD(scope_tailq, scope);
  164. void symbol_delete(symbol_t *symbol);
  165. void symtable_open(void);
  166. void symtable_close(void);
  167. symbol_t *
  168. symtable_get(char *name);
  169. symbol_node_t *
  170. symlist_search(symlist_t *symlist, char *symname);
  171. void
  172. symlist_add(symlist_t *symlist, symbol_t *symbol, int how);
  173. #define SYMLIST_INSERT_HEAD 0x00
  174. #define SYMLIST_SORT 0x01
  175. void symlist_free(symlist_t *symlist);
  176. void symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1,
  177. symlist_t *symlist_src2);
  178. void symtable_dump(FILE *ofile, FILE *dfile);