Setting up repository
[linux-libre-firmware.git] / b43-tools / 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_R5       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                 unsigned int arch;
116                 struct label *start;
117         } u;
118 };
119
120 struct statement {
121         enum {
122                 STMT_INSN,
123                 STMT_LABEL,
124                 STMT_ASMDIR,
125         } type;
126         union {
127                 struct instruction *insn;
128                 struct label *label;
129                 struct asmdir *asmdir;
130         } u;
131         struct lineinfo info;
132
133         struct list_head list;
134 };
135
136
137 struct file {
138         /* The (microcode) statement list */
139         struct list_head sl;
140         /* The initvals sections list */
141         struct list_head ivals;
142         /* The file descriptor */
143         int fd;
144 };
145
146
147 extern struct file infile;
148 extern const char *infile_name;
149 extern const char *outfile_name;
150
151 #endif /* BCM43xx_ASM_MAIN_H_ */