makerom.h
6.36 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#ifndef _MAKEROM_H_
#define _MAKEROM_H_
/**************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
#ifdef __sgi__
#include <libelf.h>
#else
#include <elf.h>
#include <libelf/libelf.h>
#endif
#include <limits.h>
#include <stdio.h>
/* Patches for IRIX 6.X and MIPSpro 7.1 have been incorporated into the
* mainline source code.
* The patch affected areas in the files makerom.c, elspec.c, and segment.c.
*
* Modifications made by Mark A. DeLoura, markdel@noa.com.
* Completed on 3/4/97.
*/
/* Patches which enable the 'romalign' keyword which was
* added to makerom by Kyoto Micro have been incorporated into the
* mainline source code.
*
* Their modifications were incorporated into this branch of makerom
* on 6/5/97 by Mark.
*/
/* Patches to use the 'objectList' flag to the linker in the final
* link stage were incorporated into the mainline source code.
*
* Modifications made by Mark A. DeLoura, markdel@noa.com.
* Completed on 6/3/97.
*/
/* Patches to do automatic alignment of sections, based on the
* requested alignment in the ELF object files, have been
* incorporated into the mainline source code. This patch gets
* around the fact that various linker versions treat the alignment
* in different ways. By doing the alignment ourselves, we ensure
* that it is treated properly, and we get around operating system
* version checks for the linker. Well, mostly.
*
* These changes were quite extensive and were completed on 6/25/97
* by Mark A. DeLoura.
*/
// Some defines for existing sections.
//
#define NO_SECTIONS 0
#define TEXT_EXISTS 1
#define DATA_EXISTS 2
#define SDATA_EXISTS 4
#define BSS_EXISTS 8
#define SBSS_EXISTS 16
typedef struct Path_s {
struct Path_s *next;
char *name;
unsigned int textSize;
unsigned int dataSize;
unsigned int sdataSize;
unsigned int sbssSize;
unsigned int bssSize;
unsigned int textAlign;
unsigned int dataAlign;
unsigned int sdataAlign;
unsigned int sbssAlign;
unsigned int bssAlign;
unsigned int textStart;
unsigned int dataStart;
unsigned int sdataStart;
unsigned int sbssStart;
unsigned int bssStart;
unsigned int sectionsExisting;
} Path;
typedef struct Segment_s {
struct Segment_s *next;
char *name;
struct Path_s *pathList;
struct Wave_s *wave;
unsigned int address;
int addrFunc;
struct Segment_s *afterSeg1;
struct Segment_s *afterSeg2;
unsigned int align;
unsigned int romOffset;
int flags;
unsigned int textSize;
unsigned int dataSize;
unsigned int sdataSize;
unsigned int sbssSize;
unsigned int bssSize;
unsigned int totalSize;
unsigned int maxSize;
int romalign;
unsigned int textAlign;
unsigned int dataAlign;
unsigned int sdataAlign;
unsigned int sbssAlign;
unsigned int bssAlign;
unsigned int sectionsExisting;
unsigned int textStart;
unsigned int dataStart;
unsigned int sdataStart;
unsigned int sbssStart;
unsigned int bssStart;
} Segment;
typedef struct SegmentChain_s {
struct SegmentChain_s *next;
struct Segment_s *segment;
} SegmentChain;
typedef struct Wave_s {
struct Wave_s *next;
char *name;
SegmentChain *segmentChain;
Elf *elf;
Elf32_Ehdr *ehdr;
char elspecFile[_POSIX_PATH_MAX];
int fd;
size_t searchIndex; /* Index used in segment.c:lookupShdr() */
} Wave;
#define SEGFLAG_BOOT 0x1
#define SEGFLAG_OBJECT 0x2
#define SEGFLAG_RAW 0x4
#define ADDRESS_NULL -1
#define ADDRFUNC_NULL 0
#define AFTERFUNC_UNARY 0x1
#define AFTERFUNC_MAX 0x2
#define AFTERFUNC_MIN 0x3
#define ADDRFUNC_ADDRESS 0x4
#define ADDRFUNC_SEGMENT 0x5
#define SizeofEntryRoutine 0x50
#define ALIGN128(i) ((((i) + 0xf) / 0x10) * 0x10)
#define ISALIGN128(i) (((i) & 0xf) == 0)
#define MIN_ADDRESS 0x00000400
#define MAX_BOOTSIZE 0x100000
#define OS_VERSION_53 0
#define OS_VERSION_62 1
#define OS_VERSION_63 2
#define OS_VERSION_64 3
#define OS_VERSION_OTHER 4
#define IDO_VERSION_53 0
#define IDO_VERSION_70 1
#define IDO_VERSION_71 2
#define IDO_VERSION_OTHER 3
#ifndef MAX
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif
#ifndef MIN
#define MIN(a,b) (((a)<(b))?(a):(b))
#endif
#define FILLBUFFER 0x2000
/*
* exports from coff.c
*/
extern int readCoff(char *, unsigned int *);
/*
* exports from elspec.c
*/
extern int createElspec(Wave *);
extern int runLinker(Wave *, char *, char *);
/*
* exports from makerom.c
*/
extern int main(int, char *[]);
extern int execCommand(char *);
extern Segment *segmentList;
extern Wave *waveList;
extern char *fileName;
extern char *bootEntryName;
extern char *bootStackName;
extern unsigned int bootStackOffset;
extern int debug;
extern int cosim;
extern int emulator;
extern int loadMap;
extern int nofont;
extern int gcord;
extern unsigned char *bootBuf, *headerBuf, *pif2bootBuf, *fontBuf;
extern int bootWordAlignedByteSize;
extern int pif2bootWordAlignedByteSize;
extern int headerWordAlignedByteSize;
extern int fontdataWordAlignedByteSize;
extern int bootAddress;
extern int finalromSize;
extern char fillData;
extern int offset;
extern int irixVersion;
extern int booter;
/*
* exports from segment.c
*/
extern int scanSegments(void);
extern int checkSizes(void);
extern int checkOverlaps(void);
extern int createSegmentSymbols(char *, char *);
extern int createRomImage(char *, char *);
extern int createEntryFile(char *, char *);
extern unsigned int ALIGNn(unsigned int romalign,int n);
/*
* exports from specgram.y (and y.tab.c)
*/
extern int yyparse(void);
extern void yyerror(char *);
/*
* exports from speclex.l (and lex.yy.c)
*/
extern int yylex(void);
extern int lineNumber;
extern FILE *yyin;
extern int yylineno;
#ifdef __sgi_
extern char yytext[];
#else
extern char *yytext;
#endif
#endif /* !_MAKEROM_H */