xref: /plan9-contrib/sys/src/9/rb/dat.h (revision 77dd0a987f922b1125641a8757e16b54f2cf323f)
1 typedef struct Conf	Conf;
2 typedef struct Confmem	Confmem;
3 typedef struct FPsave	FPsave;
4 typedef struct KMap	KMap;
5 typedef struct Lance	Lance;
6 typedef struct Lancemem	Lancemem;
7 typedef struct Label	Label;
8 typedef struct Lock	Lock;
9 typedef struct Mach	Mach;
10 typedef struct MMU	MMU;
11 typedef struct Pcidev	Pcidev;
12 typedef struct PMMU	PMMU;
13 typedef struct Rbconf	Rbconf;
14 typedef struct Softtlb	Softtlb;
15 typedef struct Ureg	Ureg;
16 typedef struct Proc	Proc;
17 typedef uvlong		Tval;
18 
19 #pragma incomplete Pcidev
20 
21 #define MAXSYSARG	5	/* for mount(fd, afd, mpt, flag, arg) */
22 
23 /*
24  *  parameters for sysproc.c and rebootcmd.c
25  */
26 #define AOUT_MAGIC	V_MAGIC || magic==M_MAGIC
27 /* r3k or r4k boot images */
28 #define BOOT_MAGIC	(0x160<<16) || magic == ((0x160<<16)|3)
29 
30 /*
31  *  machine dependent definitions used by ../port/dat.h
32  */
33 
34 struct Lock
35 {
36 	ulong	key;			/* semaphore (non-zero = locked) */
37 	ulong	sr;
38 	ulong	pc;
39 	Proc	*p;
40 	Mach	*m;
41 	ushort	isilock;
42 };
43 
44 struct Label
45 {
46 	ulong	sp;
47 	ulong	pc;
48 };
49 
50 struct Confmem
51 {
52 	ulong	base;
53 	ulong	npage;
54 	ulong	kbase;
55 	ulong	klimit;
56 };
57 
58 struct Conf
59 {
60 	ulong	nmach;		/* processors */
61 	ulong	nproc;		/* processes */
62 	Confmem	mem[1];
63 	/* npage may exclude kernel pages */
64 	ulong	npage;		/* total physical pages of memory */
65 	ulong	upages;		/* user page pool */
66 	ulong	nimage;		/* number of page cache image headers */
67 	ulong	nswap;		/* number of swap pages */
68 	int	nswppo;		/* max # of pageouts per segment pass */
69 	ulong	copymode;	/* 0 is copy on write, 1 is copy on reference */
70 	ulong	ialloc;		/* bytes available for interrupt-time allocation */
71 	ulong	pipeqsize;	/* size in bytes of pipe queues */
72 	int	nuart;		/* number of uart devices */
73 };
74 
75 struct Rbconf {
76 	char	*ether0mac;
77 	char	*memsize;
78 	char	*hz;
79 	char	*console;
80 	char	*null;		/* act as end of argv when rebooting */
81 };
82 
83 /*
84  * floating point registers
85  */
86 enum
87 {
88 	/* floating point state */
89 	FPinit,
90 	FPactive,
91 	FPinactive,
92 	FPemu,
93 
94 	/* bit meaning floating point illegal */
95 	FPillegal= 0x100,
96 };
97 
98 enum {
99 	Nfpregs		= 32,		/* floats; half as many doubles */
100 };
101 
102 /*
103  * emulated floating point (mips32r2 with ieee fp regs)
104  * fpstate is separate, kept in Proc
105  */
106 struct FPsave
107 {
108 	/* /dev/proc expects the registers to be first in FPsave */
109 	ulong	reg[Nfpregs];		/* the canonical bits */
110 	union {
111 		ulong	fpstatus;	/* both are fcr31 */
112 		ulong	fpcontrol;
113 	};
114 
115 	int	fpdelayexec;		/* executing delay slot of branch */
116 	uintptr	fpdelaypc;		/* pc to resume at after */
117 	ulong	fpdelaysts;	/* save across user-mode delay-slot execution */
118 
119 	/* stuck-fault detection */
120 	uintptr	fppc;			/* addr of last fault */
121 	int	fpcnt;			/* how many consecutive at that addr */
122 };
123 
124 int fpemudebug;
125 
126 /*
127  *  mmu goo in the Proc structure
128  */
129 struct PMMU
130 {
131 	int	pidonmach[MAXMACH];
132 };
133 
134 #include "../port/portdat.h"
135 
136 /* First FIVE members' offsets known by l.s */
137 struct Mach
138 {
139 	/* the following are all known by l.s and cannot be moved */
140 	int	machno;			/* physical id of processor FIRST */
141 	Softtlb*stb;			/* Software tlb simulation SECOND */
142 	Proc*	proc;			/* process on this processor THIRD */
143 	ulong	splpc;			/* pc that called splhi() FOURTH */
144 	ulong	tlbfault;		/* # of tlb faults FIFTH */
145 	ulong	ktlbfault;
146 	ulong	utlbfault;
147 
148 	/* the following is safe to move */
149 	ulong	tlbpurge;
150 	ulong	ticks;			/* of the clock since boot time */
151 	Label	sched;			/* scheduler wakeup */
152 	void*	alarm;			/* alarms bound to this clock */
153 	int	lastpid;		/* last pid allocated on this machine */
154 	Proc*	pidproc[NTLBPID];	/* proc that owns tlbpid on this mach */
155 	KMap*	kactive;		/* active on this machine */
156 	int	knext;
157 	uchar	ktlbx[NTLB];		/* tlb index used for kmap */
158 	uchar	ktlbnext;
159 	int	speed;			/* cpu speed */
160 	ulong	delayloop;		/* for the delay() routine */
161 	ulong	fairness;		/* for runproc */
162 	int	flushmmu;
163 	int	inclockintr;
164 	int	ilockdepth;
165 	Perf	perf;			/* performance counters */
166 	uvlong	cyclefreq;		/* Frequency of user readable cycle counter */
167 
168 	/* for per-processor timers */
169 	ulong	lastcount;
170 	uvlong	fastticks;
171 	ulong	hz;
172 	ulong	maxperiod;
173 	ulong	minperiod;
174 
175 	Proc*	readied;		/* for runproc */
176 	ulong	schedticks;		/* next forced context switch */
177 
178 	int	pfault;
179 	int	cs;
180 	int	syscall;
181 	int	load;
182 	int	intr;
183 	int	hashcoll;		/* soft-tlb hash collisions */
184 	int	paststartup;		/* for putktlb */
185 
186 	int	stack[1];
187 };
188 
189 struct KMap
190 {
191 	Ref;
192 	ulong	virt;
193 	ulong	phys0;
194 	ulong	phys1;
195 	KMap*	next;
196 	KMap*	konmach[MAXMACH];
197 	Page*	pg;
198 	ulong	pc;			/* of caller to kmap() */
199 };
200 
201 #define	VA(k)		((k)->virt)
202 #define PPN(x)		((ulong)(x)>>6)
203 
204 /* offsets known by l.s */
205 struct Softtlb
206 {
207 	ulong	virt;
208 	ulong	phys0;
209 	ulong	phys1;
210 };
211 
212 struct
213 {
214 	Lock;
215 	union {
216 		uvlong	machs;		/* bitmap of active CPUs */
217 		ulong	machsmap[(MAXMACH+BI2WD-1)/BI2WD];
218 	};
219 	int	nmachs;			/* number of bits set in machs(map) */
220 	short	exiting;
221 	int	ispanic;
222 }active;
223 
224 extern KMap kpte[];
225 extern register Mach	*m;
226 extern register Proc	*up;
227 
228 extern FPsave initfp;
229 
230 extern	int normalprint;
231 extern ulong memsize;
232 extern Rbconf rbconf;
233