xref: /plan9/sys/src/9/rb/dat.h (revision f43f8ee646e2cb29aea7fd7bb5fc7318a3f4921f)
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 Notsave	Notsave;
12 typedef struct Pcidev	Pcidev;
13 typedef struct PMMU	PMMU;
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 	ulong	npage;		/* total physical pages of memory */
64 	ulong	upages;		/* user page pool */
65 	ulong	nimage;		/* number of page cache image headers */
66 	ulong	nswap;		/* number of swap pages */
67 	int	nswppo;		/* max # of pageouts per segment pass */
68 	ulong	copymode;	/* 0 is copy on write, 1 is copy on reference */
69 	ulong	ialloc;		/* bytes available for interrupt-time allocation */
70 	ulong	pipeqsize;	/* size in bytes of pipe queues */
71 	int	nuart;		/* number of uart devices */
72 };
73 
74 /*
75  * floating point registers
76  */
77 enum
78 {
79 	/* floating point state */
80 	FPinit,
81 	FPactive,
82 	FPinactive,
83 	FPemu,
84 
85 	/* bit meaning floating point illegal */
86 	FPillegal= 0x100,
87 };
88 
89 enum {
90 	Nfpregs		= 32,		/* floats; half as many doubles */
91 };
92 
93 /*
94  * emulated floating point (mips32r2 with ieee fp regs)
95  * fpstate is separate, kept in Proc
96  */
97 struct FPsave
98 {
99 	/* /dev/proc expects the registers to be first in FPsave */
100 	ulong	reg[Nfpregs];		/* the canonical bits */
101 	union {
102 		ulong	fpstatus;	/* both are fcr31 */
103 		ulong	fpcontrol;
104 	};
105 
106 	int	fpdelayexec;		/* executing delay slot of branch */
107 	uintptr	fpdelaypc;		/* pc to resume at after */
108 	ulong	fpdelaysts;	/* save across user-mode delay-slot execution */
109 
110 	/* stuck-fault detection */
111 	uintptr	fppc;			/* addr of last fault */
112 	int	fpcnt;			/* how many consecutive at that addr */
113 };
114 
115 int fpemudebug;
116 
117 /*
118  *  mmu goo in the Proc structure
119  */
120 struct PMMU
121 {
122 	int	pidonmach[MAXMACH];
123 };
124 
125 /*
126  *  things saved in the Proc structure during a notify
127  */
128 struct Notsave
129 {
130 	ulong	nonempty;
131 };
132 
133 #include "../port/portdat.h"
134 
135 /* First FIVE members' offsets known by l.s */
136 struct Mach
137 {
138 	/* the following are all known by l.s and cannot be moved */
139 	int	machno;			/* physical id of processor FIRST */
140 	Softtlb*stb;			/* Software tlb simulation SECOND */
141 	Proc*	proc;			/* process on this processor THIRD */
142 	ulong	splpc;			/* pc that called splhi() FOURTH */
143 	ulong	tlbfault;		/* # of tlb faults FIFTH */
144 	ulong	ktlbfault;
145 	ulong	utlbfault;
146 
147 	/* the following is safe to move */
148 	ulong	tlbpurge;
149 	ulong	ticks;			/* of the clock since boot time */
150 	Label	sched;			/* scheduler wakeup */
151 	void*	alarm;			/* alarms bound to this clock */
152 	int	lastpid;		/* last pid allocated on this machine */
153 	Proc*	pidproc[NTLBPID];	/* proc that owns tlbpid on this mach */
154 	KMap*	kactive;		/* active on this machine */
155 	int	knext;
156 	uchar	ktlbx[NTLB];		/* tlb index used for kmap */
157 	uchar	ktlbnext;
158 	int	speed;			/* cpu speed */
159 	ulong	delayloop;		/* for the delay() routine */
160 	ulong	fairness;		/* for runproc */
161 	int	flushmmu;
162 	int	inclockintr;
163 	int	ilockdepth;
164 	Perf	perf;			/* performance counters */
165 	uvlong	cyclefreq;		/* Frequency of user readable cycle counter */
166 
167 	/* for per-processor timers */
168 	ulong	lastcount;
169 	uvlong	fastticks;
170 	ulong	hz;
171 	ulong	maxperiod;
172 	ulong	minperiod;
173 
174 	Proc*	readied;		/* for runproc */
175 	ulong	schedticks;		/* next forced context switch */
176 
177 	int	pfault;
178 	int	cs;
179 	int	syscall;
180 	int	load;
181 	int	intr;
182 	int	hashcoll;		/* soft-tlb hash collisions */
183 	int	paststartup;		/* for putktlb */
184 
185 	int	stack[1];
186 };
187 
188 struct KMap
189 {
190 	Ref;
191 	ulong	virt;
192 	ulong	phys0;
193 	ulong	phys1;
194 	KMap*	next;
195 	KMap*	konmach[MAXMACH];
196 	Page*	pg;
197 	ulong	pc;			/* of caller to kmap() */
198 };
199 
200 #define	VA(k)		((k)->virt)
201 #define PPN(x)		((ulong)(x)>>6)
202 
203 /* offsets known by l.s */
204 struct Softtlb
205 {
206 	ulong	virt;
207 	ulong	phys0;
208 	ulong	phys1;
209 };
210 
211 struct
212 {
213 	Lock;
214 	long	machs;		/* bitmap of processors */
215 	short	exiting;
216 	int	ispanic;
217 }active;
218 
219 extern KMap kpte[];
220 extern register Mach	*m;
221 extern register Proc	*up;
222 
223 extern FPsave initfp;
224 
225 extern	int normalprint;
226