main.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #ifndef BCM43xx_ASM_MAIN_H_
  2. #define BCM43xx_ASM_MAIN_H_
  3. #include <stdint.h>
  4. #include "list.h"
  5. #include "util.h"
  6. /* The header that fwcutter also puts in to every .fw file */
  7. struct fw_header {
  8. /* Type of the firmware data */
  9. uint8_t type;
  10. /* Version number of the firmware data format */
  11. uint8_t ver;
  12. uint8_t __padding[2];
  13. /* Size of the data. For ucode and PCM this is in bytes.
  14. * For IV this is in number-of-ivs. (big-endian!) */
  15. be32_t size;
  16. } __attribute__ ((__packed__));
  17. /* struct fw_header -> type */
  18. #define FW_TYPE_UCODE 'u'
  19. #define FW_TYPE_PCM 'p'
  20. #define FW_TYPE_IV 'i'
  21. /* struct fw_header -> ver */
  22. #define FW_HDR_VER 0x01
  23. /* Maximum number of allowed instructions in the code output.
  24. * This is what device memory can hold at maximum.
  25. */
  26. #define NUM_INSN_LIMIT_R5 4096
  27. struct lineinfo {
  28. char file[64];
  29. char linecopy[128];
  30. unsigned int lineno;
  31. unsigned int column;
  32. };
  33. extern struct lineinfo cur_lineinfo;
  34. struct immediate {
  35. unsigned int imm;
  36. };
  37. struct address {
  38. unsigned int addr;
  39. };
  40. struct registr {
  41. int type; /* SPR, GPR or OFFR */
  42. unsigned int nr;
  43. };
  44. struct memory {
  45. enum {
  46. MEM_DIRECT,
  47. MEM_INDIRECT,
  48. } type;
  49. /* Offset immediate */
  50. unsigned int offset;
  51. /* Offset Register number (only MEM_INDIRECT) */
  52. unsigned int offr_nr;
  53. };
  54. struct label {
  55. const char *name;
  56. /* direction is only used for label references. */
  57. enum {
  58. LABELREF_ABSOLUTE,
  59. LABELREF_RELATIVE_BACK,
  60. LABELREF_RELATIVE_FORWARD,
  61. } direction;
  62. };
  63. struct operand {
  64. enum {
  65. OPER_IMM,
  66. OPER_REG,
  67. OPER_MEM,
  68. OPER_LABEL,
  69. OPER_ADDR,
  70. OPER_RAW,
  71. } type;
  72. union {
  73. struct immediate *imm;
  74. struct registr *reg;
  75. struct memory *mem;
  76. struct label *label;
  77. struct address *addr;
  78. unsigned int raw;
  79. } u;
  80. };
  81. struct operlist {
  82. struct operand *oper[5];
  83. };
  84. struct instruction {
  85. int op;
  86. struct operlist *operands;
  87. unsigned int opcode; /* only for RAW */
  88. };
  89. struct asmdir {
  90. enum {
  91. ADIR_ARCH,
  92. ADIR_START,
  93. } type;
  94. union {
  95. unsigned int arch;
  96. struct label *start;
  97. } u;
  98. };
  99. struct statement {
  100. enum {
  101. STMT_INSN,
  102. STMT_LABEL,
  103. STMT_ASMDIR,
  104. } type;
  105. union {
  106. struct instruction *insn;
  107. struct label *label;
  108. struct asmdir *asmdir;
  109. } u;
  110. struct lineinfo info;
  111. struct list_head list;
  112. };
  113. struct file {
  114. /* The (microcode) statement list */
  115. struct list_head sl;
  116. /* The initvals sections list */
  117. struct list_head ivals;
  118. /* The file descriptor */
  119. int fd;
  120. };
  121. extern struct file infile;
  122. extern const char *infile_name;
  123. extern const char *outfile_name;
  124. #endif /* BCM43xx_ASM_MAIN_H_ */