summaryrefslogtreecommitdiffstats
path: root/assembler/main.h
blob: f5c22342c4dba1d71404f7750e9d2ac3dc49064e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#ifndef BCM43xx_ASM_MAIN_H_
#define BCM43xx_ASM_MAIN_H_

#include <stdint.h>

#include "list.h"
#include "util.h"


/* The header that fwcutter also puts in to every .fw file */
struct fw_header {
	/* Type of the firmware data */
	uint8_t type;
	/* Version number of the firmware data format */
	uint8_t ver;
	uint8_t __padding[2];
	/* Size of the data. For ucode and PCM this is in bytes.
	 * For IV this is in number-of-ivs. (big-endian!) */
	be32_t size;
} __attribute__ ((__packed__));

/* struct fw_header -> type */
#define FW_TYPE_UCODE	'u'
#define FW_TYPE_PCM	'p'
#define FW_TYPE_IV	'i'
/* struct fw_header -> ver */
#define FW_HDR_VER	0x01


/* Maximum number of allowed instructions in the code output.
 * This is what device memory can hold at maximum.
 */
#define NUM_INSN_LIMIT_R5	4096


struct lineinfo {
	char file[64];
	char linecopy[128];
	unsigned int lineno;
	unsigned int column;
};
extern struct lineinfo cur_lineinfo;


struct immediate {
	unsigned int imm;
};

struct address {
	unsigned int addr;
};

struct registr {
	int type; /* SPR, GPR or OFFR */
	unsigned int nr;
};

struct memory {
	enum {
		MEM_DIRECT,
		MEM_INDIRECT,
	} type;
	/* Offset immediate */
	unsigned int offset;
	/* Offset Register number (only MEM_INDIRECT) */
	unsigned int offr_nr;
};

struct label {
	const char *name;

	/* direction is only used for label references. */
	enum {
		LABELREF_ABSOLUTE,
		LABELREF_RELATIVE_BACK,
		LABELREF_RELATIVE_FORWARD,
	} direction;
};

struct operand {
	enum {
		OPER_IMM,
		OPER_REG,
		OPER_MEM,
		OPER_LABEL,
		OPER_ADDR,
		OPER_RAW,
	} type;
	union {
		struct immediate *imm;
		struct registr *reg;
		struct memory *mem;
		struct label *label;
		struct address *addr;
		unsigned int raw;
	} u;
};

struct operlist {
	struct operand *oper[5];
};

struct instruction {
	int op;
	struct operlist *operands;
	unsigned int opcode; /* only for RAW */
};

struct asmdir {
	enum {
		ADIR_ARCH,
		ADIR_START,
	} type;
	union {
		unsigned int arch;
		struct label *start;
	} u;
};

struct statement {
	enum {
		STMT_INSN,
		STMT_LABEL,
		STMT_ASMDIR,
	} type;
	union {
		struct instruction *insn;
		struct label *label;
		struct asmdir *asmdir;
	} u;
	struct lineinfo info;

	struct list_head list;
};


struct file {
	/* The (microcode) statement list */
	struct list_head sl;
	/* The initvals sections list */
	struct list_head ivals;
	/* The file descriptor */
	int fd;
};


extern struct file infile;
extern const char *infile_name;
extern const char *outfile_name;

#endif /* BCM43xx_ASM_MAIN_H_ */
bues.ch cgit interface