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