Subversion Repositories planix.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include	<u.h>
2
#include	<libc.h>
3
#include	<bio.h>
4
#include	<mach.h>
5
		/* table for selecting machine-dependent parameters */
6
 
7
typedef	struct machtab Machtab;
8
 
9
struct machtab
10
{
11
	char		*name;			/* machine name */
12
	short		type;			/* executable type */
13
	short		boottype;		/* bootable type */
14
	int		asstype;		/* disassembler code */
15
	Mach		*mach;			/* machine description */
16
	Machdata	*machdata;		/* machine functions */
17
};
18
 
19
extern	Mach		mmips, msparc, m68020, mi386, mamd64,
20
			marm, mmips2be, mmips2le, mpower, mpower64, malpha, msparc64;
21
extern	Machdata	mipsmach, mipsmachle, sparcmach, m68020mach, i386mach,
22
			armmach, mipsmach2le, powermach, alphamach, sparc64mach;
23
 
24
/*
25
 *	machine selection table.  machines with native disassemblers should
26
 *	follow the plan 9 variant in the table; native modes are selectable
27
 *	only by name.
28
 */
29
Machtab	machines[] =
30
{
31
	{	"68020",			/*68020*/
32
		F68020,
33
		F68020B,
34
		A68020,
35
		&m68020,
36
		&m68020mach,	},
37
	{	"68020",			/*Next 68040 bootable*/
38
		F68020,
39
		FNEXTB,
40
		A68020,
41
		&m68020,
42
		&m68020mach,	},
43
	{	"mips2LE",			/*plan 9 mips2 little endian*/
44
		FMIPS2LE,
45
		0,
46
		AMIPS,
47
		&mmips2le,
48
		&mipsmach2le, 	},
49
	{	"mipsLE",				/*plan 9 mips little endian*/
50
		FMIPSLE,
51
		0,
52
		AMIPS,
53
		&mmips,
54
		&mipsmachle, 	},
55
	{	"mips",				/*plan 9 mips*/
56
		FMIPS,
57
		FMIPSB,
58
		AMIPS,
59
		&mmips,
60
		&mipsmach, 	},
61
	{	"mips2",			/*plan 9 mips2*/
62
		FMIPS2BE,
63
		FMIPSB,
64
		AMIPS,
65
		&mmips2be,
66
		&mipsmach, 	},		/* shares debuggers with native mips */
67
	{	"mipsco",			/*native mips - must follow plan 9*/
68
		FMIPS,
69
		FMIPSB,
70
		AMIPSCO,
71
		&mmips,
72
		&mipsmach,	},
73
	{	"sparc",			/*plan 9 sparc */
74
		FSPARC,
75
		FSPARCB,
76
		ASPARC,
77
		&msparc,
78
		&sparcmach,	},
79
	{	"sunsparc",			/*native sparc - must follow plan 9*/
80
		FSPARC,
81
		FSPARCB,
82
		ASUNSPARC,
83
		&msparc,
84
		&sparcmach,	},
85
	{	"386",				/*plan 9 386*/
86
		FI386,
87
		FI386B,
88
		AI386,
89
		&mi386,
90
		&i386mach,	},
91
	{	"86",				/*8086 - a peach of a machine*/
92
		FI386,
93
		FI386B,
94
		AI8086,
95
		&mi386,
96
		&i386mach,	},
97
	{	"amd64",			/*amd64*/
98
		FAMD64,
99
		FAMD64B,
100
		AAMD64,
101
		&mamd64,
102
		&i386mach,	},
103
	{	"arm",				/*ARM*/
104
		FARM,
105
		FARMB,
106
		AARM,
107
		&marm,
108
		&armmach,	},
109
	{	"power",			/*PowerPC*/
110
		FPOWER,
111
		FPOWERB,
112
		APOWER,
113
		&mpower,
114
		&powermach,	},
115
	{	"power64",			/*PowerPC*/
116
		FPOWER64,
117
		FPOWER64B,
118
		APOWER64,
119
		&mpower64,
120
		&powermach,	},
121
	{	"alpha",			/*Alpha*/
122
		FALPHA,
123
		FALPHAB,
124
		AALPHA,
125
		&malpha,
126
		&alphamach,	},
127
	{	"sparc64",			/*plan 9 sparc64 */
128
		FSPARC64,
129
		FSPARCB,			/* XXX? */
130
		ASPARC64,
131
		&msparc64,
132
		&sparc64mach,	},
133
	{	0		},		/*the terminator*/
134
};
135
 
136
/*
137
 *	select a machine by executable file type
138
 */
139
void
140
machbytype(int type)
141
{
142
	Machtab *mp;
143
 
144
	for (mp = machines; mp->name; mp++){
145
		if (mp->type == type || mp->boottype == type) {
146
			asstype = mp->asstype;
147
			machdata = mp->machdata;
148
			break;
149
		}
150
	}
151
}
152
/*
153
 *	select a machine by name
154
 */
155
int
156
machbyname(char *name)
157
{
158
	Machtab *mp;
159
 
160
	if (!name) {
161
		asstype = AMIPS;
162
		machdata = &mipsmach;
163
		mach = &mmips;
164
		return 1;
165
	}
166
	for (mp = machines; mp->name; mp++){
167
		if (strcmp(mp->name, name) == 0) {
168
			asstype = mp->asstype;
169
			machdata = mp->machdata;
170
			mach = mp->mach;
171
			return 1;
172
		}
173
	}
174
	return 0;
175
}