xref: /inferno-os/os/boot/mpc/dat.h (revision 74a4d8c26dd3c1e9febcb717cfd6cb6512991a7a)
1 typedef struct Alarm Alarm;
2 typedef struct Block Block;
3 typedef struct IMM IMM;
4 typedef struct Queue Queue;
5 
6 typedef struct List {
7 	void	*next;
8 } List;
9 
10 typedef struct {
11 	int	fake;
12 	int	pri;
13 } Lock;
14 #define	lock(x)
15 #define	unlock(x)
16 
17 struct Alarm {
18 	List;
19 	int	busy;
20 	long	dt;
21 	void	(*f)(Alarm*);
22 	void	*arg;
23 };
24 
25 enum {
26 	Eaddrlen	= 6,
27 	ETHERMINTU	= 60,		/* minimum transmit size */
28 	ETHERMAXTU	= 1514,		/* maximum transmit size */
29 	ETHERHDRSIZE	= 14,		/* size of an ethernet header */
30 
31 	MaxEther	= 4,
32 };
33 
34 typedef struct {
35 	uchar	d[Eaddrlen];
36 	uchar	s[Eaddrlen];
37 	uchar	type[2];
38 	uchar	data[1500];
39 	uchar	crc[4];
40 } Etherpkt;
41 
42 extern uchar broadcast[Eaddrlen];
43 
44 enum {
45 	Npart		= 20+2,		/* 8 sub partitions, disk, and partition */
46 	Maxxfer		= 16*1024,	/* maximum transfer size/cmd */
47 };
48 
49 typedef struct {
50 	ulong	start;
51 	ulong	end;
52 	char	name[NAMELEN+1];
53 } Partition;
54 
55 typedef struct {
56 	int	online;
57 	int	npart;		/* number of real partitions */
58 	Partition p[Npart];
59 	ulong	offset;
60 	Partition *current;	/* current partition */
61 
62 	ulong	cap;		/* total bytes */
63 	int	bytes;		/* bytes/sector */
64 	int	sectors;	/* sectors/track */
65 	int	heads;		/* heads/cyl */
66 	long	cyl;		/* cylinders/drive */
67 
68 	char	lba;		/* true if drive has logical block addressing */
69 	char	multi;		/* non-zero if drive does multiple block xfers */
70 } Disc;
71 
72 enum {
73 	ScsiTestunit	= 0x00,
74 	ScsiExtsens	= 0x03,
75 	ScsiInquiry	= 0x12,
76 	ScsiModesense	= 0x1a,
77 	ScsiStartunit	= 0x1B,
78 	ScsiStopunit	= 0x1B,
79 	ScsiGetcap	= 0x25,
80 	ScsiRead	= 0x08,
81 	ScsiWrite	= 0x0a,
82 	ScsiExtread	= 0x28,
83 	ScsiExtwrite	= 0x2a,
84 
85 	/* data direction */
86 	ScsiIn		= 1,
87 	ScsiOut		= 0,
88 };
89 
90 typedef struct Scsibuf Scsibuf;
91 typedef struct Scsibuf {
92 	void*		virt;
93 	void*		phys;
94 	Scsibuf*	next;
95 };
96 
97 typedef struct Scsidata {
98 	uchar*		base;
99 	uchar*		lim;
100 	uchar*		ptr;
101 } Scsidata;
102 
103 typedef struct Ureg Ureg;
104 
105 typedef struct Scsi {
106 	ulong		pid;
107 	ushort		target;
108 	ushort		lun;
109 	ushort		rflag;
110 	ushort		status;
111 	Scsidata 	cmd;
112 	Scsidata 	data;
113 	Scsibuf*	b;
114 	uchar*		save;
115 	uchar		cmdblk[16];
116 } Scsi;
117 
118 typedef struct Segdesc {
119 	ulong	d0;
120 	ulong	d1;
121 } Segdesc;
122 
123 typedef struct Mach {
124 	ulong	ticks;			/* of the clock since boot time */
125 	ulong	delayloop;
126 	long	cpuhz;	/* general system clock (cycles) */
127 	long	clockgen;	/* clock generator frequency (cycles) */
128 	ulong	cpupvr;	/* cpu type in processor version register */
129 	ulong	cputype;	/* cpu variant in BCD (eg, 0x823xx) */
130 	void*	alarm;			/* alarms bound to this clock */
131 	ulong*	bcsr;
132 	IMM*	iomem;
133 } Mach;
134 
135 /* Mach.cputype */
136 #define MPCREV(x)	((x) & 0xFF)
137 #define MPCMODEL(x)	(((x)>>8) & 0xFFF)
138 #define MPCFAMILY(x)	(((x)>>24) & 0x0F)
139 
140 
141 extern Mach *m;
142 
143 #define Q_MAGIC		((((4*21)+0)*21)+7)
144 
145 typedef struct Exec Exec;
146 struct	Exec
147 {
148 	uchar	magic[4];		/* magic number */
149 	uchar	text[4];	 	/* size of text segment */
150 	uchar	data[4];	 	/* size of initialized data */
151 	uchar	bss[4];	  		/* size of uninitialized data */
152 	uchar	syms[4];	 	/* size of symbol table */
153 	uchar	entry[4];	 	/* entry point */
154 	uchar	spsz[4];		/* size of sp/pc offset table */
155 	uchar	pcsz[4];		/* size of pc/line number table */
156 };
157 
158 /*
159  *  bootline passed by boot program
160  */
161 #define BOOTLINE ((char *)0x200000-150)
162 
163 /*
164  * Where we leave configuration info.
165  */
166 #define BOOTARGS	((char*)(0x200000))
167 #define	BOOTARGSLEN	1024
168 #define	MAXCONF		32
169 
170 /*
171  *  a parsed plan9.ini line
172  */
173 #define ISAOPTLEN	16
174 #define NISAOPT		8
175 
176 typedef struct  ISAConf {
177 	char	type[NAMELEN];
178 	ulong	port;
179 	ulong	irq;
180 	ulong	mem;
181 	ulong	size;
182 	uchar	ea[6];
183 
184 	int	nopt;
185 	char	opt[NISAOPT][ISAOPTLEN];
186 } ISAConf;
187 
188 typedef struct {
189 	int	size;
190 	ulong	addr;
191 } Map;
192 
193 typedef struct {
194 	char*	name;
195 	Map*	map;
196 	Map*	mapend;
197 
198 	Lock;
199 } RMap;
200 
201 typedef struct PCIcfg PCIcfg;
202 
203 extern	uchar*	vgamem;
204 
205 struct Block {
206 	uchar	*rp;
207 	uchar	*wp;
208 	uchar	*lim;
209 	uchar	*data;
210 	Block*	next;
211 	ulong	magic;
212 };
213 #define	BLEN(b)	((b)->wp-(b)->rp)
214 
215 typedef struct QLock {
216 	int	dummy;
217 } QLock;
218