aicasm_symbol.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. #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. int count;
  118. union {
  119. struct reg_info *rinfo;
  120. struct field_info *finfo;
  121. struct const_info *cinfo;
  122. struct alias_info *ainfo;
  123. struct label_info *linfo;
  124. struct cond_info *condinfo;
  125. struct macro_info *macroinfo;
  126. } info;
  127. int dont_generate_debug_code;
  128. } symbol_t;
  129. typedef struct symbol_ref {
  130. symbol_t *symbol;
  131. int offset;
  132. } symbol_ref_t;
  133. typedef struct symbol_node {
  134. SLIST_ENTRY(symbol_node) links;
  135. symbol_t *symbol;
  136. } symbol_node_t;
  137. typedef struct critical_section {
  138. TAILQ_ENTRY(critical_section) links;
  139. int begin_addr;
  140. int end_addr;
  141. } critical_section_t;
  142. typedef enum {
  143. SCOPE_ROOT,
  144. SCOPE_IF,
  145. SCOPE_ELSE_IF,
  146. SCOPE_ELSE
  147. } scope_type;
  148. typedef struct patch_info {
  149. int skip_patch;
  150. int skip_instr;
  151. } patch_info_t;
  152. typedef struct scope {
  153. SLIST_ENTRY(scope) scope_stack_links;
  154. TAILQ_ENTRY(scope) scope_links;
  155. TAILQ_HEAD(, scope) inner_scope;
  156. scope_type type;
  157. int inner_scope_patches;
  158. int begin_addr;
  159. int end_addr;
  160. patch_info_t patches[2];
  161. int func_num;
  162. } scope_t;
  163. TAILQ_HEAD(cs_tailq, critical_section);
  164. SLIST_HEAD(scope_list, scope);
  165. TAILQ_HEAD(scope_tailq, scope);
  166. void symbol_delete(symbol_t *symbol);
  167. void symtable_open(void);
  168. void symtable_close(void);
  169. symbol_t *
  170. symtable_get(char *name);
  171. symbol_node_t *
  172. symlist_search(symlist_t *symlist, char *symname);
  173. void
  174. symlist_add(symlist_t *symlist, symbol_t *symbol, int how);
  175. #define SYMLIST_INSERT_HEAD 0x00
  176. #define SYMLIST_SORT 0x01
  177. void symlist_free(symlist_t *symlist);
  178. void symlist_merge(symlist_t *symlist_dest, symlist_t *symlist_src1,
  179. symlist_t *symlist_src2);
  180. void symtable_dump(FILE *ofile, FILE *dfile);