File: mvmebug.h

package info (click to toggle)
m68k-vme-tftplilo 1.0.0-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 316 kB
  • ctags: 637
  • sloc: ansic: 5,475; makefile: 78
file content (347 lines) | stat: -rw-r--r-- 7,040 bytes parent folder | download
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
/*
 *  VME Linux/m68k TFTP Loader
 *
 *  (c) Copyright 1998 by Nick Holgate
 *
 *  This file is subject to the terms and conditions of the GNU General Public
 *  License.  See the file COPYING for more details.
 */

/*--------------------------------------------------------------------------*/

#define MVMEBugEntry			15		/* Trap #15 to call MVMEBug */

#define MB_OUTCHR			0x0020
#define MB_OUTSTR			0x0021
#define MB_WRITD			0x0028
#define MB_INCHR			0x0000
#define MB_INSTAT			0x0001
#define MB_DSKRD			0x0010
#define MB_SYMBOLTA			0x0130
#define MB_SYMBOLTD			0x0131
#define MB_RETURN			0x0063
#define MB_RTC_READ			0x0053
#define MB_NETRD			0x0018
#define MB_NETWR			0x0019

/*--------------------------------------------------------------------------*/
/* system call .NETRD/.NETWR packet template
 */

typedef struct niopcall {
	unsigned char	clun;			/* controller logical unit number		*/
	unsigned char	dlun;			/* device logical unit number			*/
	unsigned short	status;			/* error status word					*/
	unsigned long	address;		/* data transfer address				*/
	unsigned long	length;			/* maximum length of transfer			*/
	unsigned long	offset;			/* byte offset							*/
	unsigned long	time;			/* transfer time in seconds (status)	*/
	unsigned long	bytes;			/* transfer byte count (status)			*/
	unsigned char	filename[64];	/* boot filename buffer string			*/

} NIOPCALL;

/*--------------------------------------------------------------------------*/
/* network boot information block structure template
 */

typedef struct netbootinfo {
	unsigned long	cipa;			/* client IP address 					*/
	unsigned long	sipa;			/* server IP address					*/
	unsigned long	gipa;			/* gateway IP address					*/
	unsigned long	subnetmask;		/* subnet IP address mask				*/
	unsigned long	broadcast;		/* broadcast IP address					*/

} NETBOOTINFO;

/*--------------------------------------------------------------------------*/
/* Disk Read command block
 */
typedef struct {
	unsigned char	clun,
					dlun;
	unsigned short	status;
	unsigned long	address,
					block;
	unsigned short	count;
	unsigned char	flags,
					mod;
} DSKRD_CMND;

/*--------------------------------------------------------------------------*/

/*
        32 bit word at  0x14 block number of start of kernel
        16 bit word at  0x18 number of blocks to load
        32 bit word at  0x1E boot load address
        32 bit word at 0x90 to contain 0 (Media config area start block)
        Locations 0xF8 to 0xFF to contain "MOTOROLA"
*/

#define MAX_LDR_FRAGS	5

typedef struct {
	unsigned long sp, pc;				/* 00								*/
	char		filler1[12];			/* 00								*/
	unsigned long boot_start_block;		/* 14 bootfile start block addr		*/
	unsigned short boot_block_count;	/* 18 number of blocks in file		*/
	char		filler2[4];				/* 1a								*/
	unsigned long boot_load_addr;		/* 1e 								*/
	char		filler3[14];			/* 22								*/
	char		boot_code[0x60];		/* 30								*/
	unsigned long zero;					/* 90								*/
	char		filler4[12];			/* 94								*/
	DSKRD_CMND	cdb[MAX_LDR_FRAGS];		/* a0								*/
	char		boot_id[16];			/* f0 id string "Linux68kMOTOROLA"	*/
} BOOTBLOCK;

#define BOOT_BLOCK_ID  "Linux68kMOTOROLA"

/*--------------------------------------------------------------------------*/
/* Call MVMEBug putchar subroutine.
 */

static
__inline__
void
MVMEBug_putchar
(	int		c
)
{	register unsigned long	d0 asm("d0") = (unsigned long) c;

	asm volatile (
		"	move.b	%%d0,-(%%sp)
			trap	#15
			dc.w	0x0020
		"
		: /* no outputs */
		: "r" (d0)
		: "d0"
	);
}

/*--------------------------------------------------------------------------*/
/* Call MVMEBug putstr subroutine.
 */

static
__inline__
void
MVMEBug_putstr
(	const char		*str,
	const char		*end
)
{	register void			*a0 asm("a0") = (void *) str;
	register void			*a1 asm("a1") = (void *) end;

	asm volatile (
		"	move.l	%%a1,-(%%sp)
			move.l	%%a0,-(%%sp)
			trap	#15
			dc.w	0x0021
		"
		: /* no outputs */
		: "r" (a0), "r" (a1)
		: "a0", "a1"
	);
}

/*--------------------------------------------------------------------------*/
/* Call MVMEBug print subroutine.
 */

static
__inline__
void
MVMEBug_print
(	const char		*str,
	void			*vap
)
{	register void			*a0 asm("a0") = (void *) str;
	register void			*a1 asm("a1") = (void *) vap;

	asm volatile (
		"	move.l	%%a1,-(%%sp)
			move.l	%%a0,-(%%sp)
			trap	#15
			dc.w	0x0028
		"
		: /* no outputs */
		: "r" (a0), "r" (a1)
		: "a0", "a1"
	);
}

/*--------------------------------------------------------------------------*/
/* Call MVMEBug getchar subroutine.
 */

static
__inline__
int
MVMEBug_getchar
(	void
)
{	register unsigned long	d0 asm("d0") = 0;

	asm volatile (
		"	subq.l	#2,%%sp
			trap	#15
			dc.w	0x0000
			move.b	(%%sp)+,%%d0
		"
		: "=r" (d0)
		: "r" (d0)
		: "d0"
	);

	return d0;
}

/*--------------------------------------------------------------------------*/
/* Call MVMEBug input status subroutine.
 */

static
__inline__
int
MVMEBug_getchar_status
(	void
)
{	register unsigned long	d0 asm("d0");

	asm volatile (
		"	move.l	#0,-(%%sp)
			trap	#15
			dc.w	0x0001
			beq.s	1f
			move.l	#1,(%%sp)
		1:
			move.l	(%%sp)+,%%d0
		"
		: "=r" (d0)
		: /* no inputs */
		: "d0"
	);

	return d0;
}

/*--------------------------------------------------------------------------*/
/* Call MVMEBug RTC read subroutine.
 */

static
__inline__
void
MVMEBug_rtc_read
(	void			*buf
)
{	register void *			d0 asm("d0") = (void *) buf;

	asm volatile (
		"	move.l	%%d0,-(%%sp)
			trap	#15
			dc.w	0x0053
		"
		: /* no outputs */
		: "r" (d0)
		: "d0"
	);
}

/*--------------------------------------------------------------------------*/
/* Call MVMEBug disk_read subroutine.
 */

static
__inline__
void
MVMEBug_disk_read
(	void			*cmnd
)
{	register void	*d0 asm("d0") = (void *) cmnd;

	asm volatile (
		"	move.l	%%d0,-(%%sp)
			trap	#15
			dc.w	0x0010
		"
		: /* no outputs */
		: "r" (d0)
		: "d0", "memory"
	);
}

/*--------------------------------------------------------------------------*/
/* Call MVMEBug disk_read subroutine.
 */

static
__inline__
void
MVMEBug_net_read
(	NIOPCALL	*niop
)
{	register void *d0 asm("d0") = (void *) niop;

	asm volatile (
		"	move.l	%%d0,-(%%sp)
			trap	#15
			dc.w	0x0018
		"
		: /* no outputs */
		: "r" (d0)
		: "d0", "memory"
	);
}

/*--------------------------------------------------------------------------*/
/* Call MVMEBug.
 */

static
__inline__
void
MVMEBug_enter
(	void
)
{
	asm volatile (
		"	trap	#15
			dc.w	0x0063
		"
		: /* No outputs */
		: /* No inputs  */
		: "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
		  "a0", "a1", "a2", "a3", "a4", "a5", "a6", "memory"
	);
}

/*--------------------------------------------------------------------------*/
/* Call MVMEBug BRD_ID subroutine.
 */

static
__inline__
void *
MVMEBug_brd_id
(	void
)
{	register void *			d0 asm("d0");

	asm volatile (
		"	subq.l	#4,%%sp
			trap	#15
			dc.w	0x0070
			move.l	(%%sp)+,%%d0
		"
		: "=r" (d0)
		: /* no inputs */
		: "d0"
	);

	return d0;
}

/*-----------------------------< end of file >------------------------------*/