summaryrefslogtreecommitdiff
path: root/os/boot/rpcg/dat.h
blob: edadc030ded1aa14b3fa6f655a918c2aebf8bd41 (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
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
typedef struct Alarm Alarm;
typedef struct Block Block;
typedef struct IMM IMM;
typedef struct Queue Queue;

typedef struct List {
	void	*next;
} List;

typedef struct {
	int	fake;
	int	pri;
} Lock;
#define	lock(x)
#define	unlock(x)

struct Alarm {
	List;
	int	busy;
	long	dt;
	void	(*f)(Alarm*);
	void	*arg;
};

enum {
	Eaddrlen	= 6,
	ETHERMINTU	= 60,		/* minimum transmit size */
	ETHERMAXTU	= 1514,		/* maximum transmit size */
	ETHERHDRSIZE	= 14,		/* size of an ethernet header */

	MaxEther	= 4,
};

typedef struct {
	uchar	d[Eaddrlen];
	uchar	s[Eaddrlen];
	uchar	type[2];
	uchar	data[1500];
	uchar	crc[4];
} Etherpkt;

extern uchar broadcast[Eaddrlen];

enum {
	Npart		= 20+2,		/* 8 sub partitions, disk, and partition */
	Maxxfer		= 16*1024,	/* maximum transfer size/cmd */
};

typedef struct {
	ulong	start;
	ulong	end;
	char	name[NAMELEN+1];
} Partition;

typedef struct {
	int	online;
	int	npart;		/* number of real partitions */
	Partition p[Npart];
	ulong	offset;
	Partition *current;	/* current partition */

	ulong	cap;		/* total bytes */
	int	bytes;		/* bytes/sector */
	int	sectors;	/* sectors/track */
	int	heads;		/* heads/cyl */
	long	cyl;		/* cylinders/drive */

	char	lba;		/* true if drive has logical block addressing */
	char	multi;		/* non-zero if drive does multiple block xfers */
} Disc;

enum {
	ScsiTestunit	= 0x00,
	ScsiExtsens	= 0x03,
	ScsiInquiry	= 0x12,
	ScsiModesense	= 0x1a,
	ScsiStartunit	= 0x1B,
	ScsiStopunit	= 0x1B,
	ScsiGetcap	= 0x25,
	ScsiRead	= 0x08,
	ScsiWrite	= 0x0a,
	ScsiExtread	= 0x28,
	ScsiExtwrite	= 0x2a,

	/* data direction */
	ScsiIn		= 1,
	ScsiOut		= 0,
};

typedef struct Scsibuf Scsibuf;
typedef struct Scsibuf {
	void*		virt;
	void*		phys;
	Scsibuf*	next;
};

typedef struct Scsidata {
	uchar*		base;
	uchar*		lim;
	uchar*		ptr;
} Scsidata;

typedef struct Ureg Ureg;

typedef struct Scsi {
	ulong		pid;
	ushort		target;
	ushort		lun;
	ushort		rflag;
	ushort		status;
	Scsidata 	cmd;
	Scsidata 	data;
	Scsibuf*	b;
	uchar*		save;
	uchar		cmdblk[16];
} Scsi;

typedef struct Segdesc {
	ulong	d0;
	ulong	d1;
} Segdesc;

typedef struct Mach {
	ulong	ticks;			/* of the clock since boot time */
	ulong	delayloop;
	long	cpuhz;	/* general system clock (cycles) */
	long	clockgen;	/* clock generator frequency (cycles) */
	ulong	cpupvr;	/* cpu type in processor version register */
	ulong	cputype;	/* cpu variant in BCD (eg, 0x823xx) */
	void*	alarm;			/* alarms bound to this clock */
	ulong*	bcsr;
	IMM*	iomem;
} Mach;

/* Mach.cputype */
#define MPCREV(x)	((x) & 0xFF)
#define MPCMODEL(x)	(((x)>>8) & 0xFFF)
#define MPCFAMILY(x)	(((x)>>24) & 0x0F)


extern Mach *m;

#define Q_MAGIC		((((4*21)+0)*21)+7)

typedef struct Exec Exec;
struct	Exec
{
	uchar	magic[4];		/* magic number */
	uchar	text[4];	 	/* size of text segment */
	uchar	data[4];	 	/* size of initialized data */
	uchar	bss[4];	  		/* size of uninitialized data */
	uchar	syms[4];	 	/* size of symbol table */
	uchar	entry[4];	 	/* entry point */
	uchar	spsz[4];		/* size of sp/pc offset table */
	uchar	pcsz[4];		/* size of pc/line number table */
};

/*
 *  bootline passed by boot program
 */
#define BOOTLINE ((char *)0x200000-150)

/*
 * Where we leave configuration info.
 */
#define BOOTARGS	((char*)(0x200000))
#define	BOOTARGSLEN	1024
#define	MAXCONF		32

/*
 *  a parsed plan9.ini line
 */
#define ISAOPTLEN	16
#define NISAOPT		8

typedef struct  ISAConf {
	char	type[NAMELEN];
	ulong	port;
	ulong	irq;
	ulong	mem;
	ulong	size;
	uchar	ea[6];

	int	nopt;
	char	opt[NISAOPT][ISAOPTLEN];
} ISAConf;

typedef struct {
	int	size;
	ulong	addr;
} Map;

typedef struct {
	char*	name;
	Map*	map;
	Map*	mapend;

	Lock;
} RMap;

typedef struct PCIcfg PCIcfg;

extern	uchar*	vgamem;

struct Block {
	uchar	*rp;
	uchar	*wp;
	uchar	*lim;
	uchar	*data;
	Block*	next;
	ulong	magic;
};
#define	BLEN(b)	((b)->wp-(b)->rp)

typedef struct QLock {
	int	dummy;
} QLock;