xref: /plan9-contrib/sys/src/9/loongson64/dat.h (revision 77dd0a987f922b1125641a8757e16b54f2cf323f)
1 typedef struct Conf	Conf;
2 typedef struct Confmem	Confmem;
3 typedef struct FPsave	FPsave;
4 typedef struct ISAConf	ISAConf;
5 typedef struct KMap	KMap;
6 typedef struct Lance	Lance;
7 typedef struct Lancemem	Lancemem;
8 typedef struct Label	Label;
9 typedef struct Lock	Lock;
10 typedef struct Mach	Mach;
11 typedef struct MMU	MMU;
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	N_MAGIC || magic==P_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 	uintptr	pc;
39 	Proc	*p;
40 	Mach	*m;
41 	ushort	isilock;
42 };
43 
44 struct Label
45 {
46 	uintptr	sp;
47 	uintptr	pc;
48 };
49 
50 struct Confmem
51 {
52 	uintptr	base;
53 	ulong	npage;
54 	uintptr	kbase;
55 	uintptr	klimit;
56 };
57 
58 struct Conf
59 {
60 	ulong	nmach;		/* processors */
61 	ulong	nproc;		/* processes */
62 	Confmem	mem[2];		/* physical memory */
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 	int	monitor;	/* has monitor? */
73 };
74 
75 /*
76  * floating point registers
77  */
78 enum
79 {
80 	/* floating point state */
81 	FPinit,
82 	FPactive,
83 	FPinactive,
84 	FPemu,
85 
86 	/* bit meaning floating point illegal */
87 	FPillegal= 0x100,
88 };
89 
90 enum {
91 	Nfpregs		= 32,		/* floats; half as many doubles */
92 };
93 
94 /*
95  * floating point
96  * fpstate is separate, kept in Proc
97  */
98 struct FPsave
99 {
100 	/* /dev/proc expects the registers to be first in FPsave */
101 	ulong	reg[Nfpregs];		/* the canonical bits */
102 	union {
103 		ulong	fpstatus;	/* both are fcr31 */
104 		ulong	fpcontrol;
105 	};
106 
107 	int	fpdelayexec;		/* executing delay slot of branch */
108 	uintptr	fpdelaypc;		/* pc to resume at after */
109 	ulong	fpdelaysts;	/* save across user-mode delay-slot execution */
110 
111 	/* stuck-fault detection */
112 	uintptr	fppc;			/* addr of last fault */
113 	int	fpcnt;			/* how many consecutive at that addr */
114 };
115 
116 /*
117  *  mmu goo in the Proc structure
118  */
119 struct PMMU
120 {
121 	int	pidonmach[MAXMACH];
122 };
123 
124 #include "../port/portdat.h"
125 
126 /* First FIVE members' offsets known by l.s */
127 struct Mach
128 {
129 	/* the following are all known by l.s and cannot be moved */
130 	int		machno;			/* physical id of processor FIRST @ 0 */
131 	Softtlb*stb;			/* Software tlb simulation SECOND @ 8 */
132 	Proc*	proc;			/* process on this processor THIRD @ 16 */
133 	uintptr	splpc;			/* pc that called splhi() FOURTH @ 24 */
134 	ulong	tlbfault;		/* # of tlb faults FIFTH @ 32 */
135 	ulong	ktlbfault;		/* @ 36 */
136 	ulong	utlbfault;		/* @ 40 */
137 
138 	/* the following is safe to move */
139 	ulong	tlbpurge;
140 	ulong	ticks;			/* of the clock since boot time */
141 	Label	sched;			/* scheduler wakeup */
142 	void*	alarm;			/* alarms bound to this clock */
143 	int	lastpid;		/* last pid allocated on this machine */
144 	Proc*	pidproc[NTLBPID];	/* proc that owns tlbpid on this mach */
145 	KMap*	kactive;		/* active on this machine */
146 	int	knext;
147 	uchar	ktlbx[NTLB];		/* tlb index used for kmap */
148 	uchar	ktlbnext;
149 	int	speed;			/* cpu speed */
150 	ulong	delayloop;		/* for the delay() routine */
151 	ulong	fairness;		/* for runproc */
152 	int	flushmmu;
153 	int	inclockintr;
154 	int	ilockdepth;
155 	Perf	perf;			/* performance counters */
156 	uvlong	cyclefreq;		/* Frequency of user readable cycle counter */
157 
158 	/* for per-processor timers */
159 	ulong	lastcount;
160 	uvlong	fastticks;
161 	ulong	hz;
162 	ulong	maxperiod;
163 	ulong	minperiod;
164 
165 	Proc*	readied;		/* for runproc */
166 	ulong	schedticks;		/* next forced context switch */
167 
168 	int	pfault;
169 	int	cs;
170 	int	syscall;
171 	int	load;
172 	int	intr;
173 	int	hashcoll;		/* soft-tlb hash collisions */
174 	int	paststartup;		/* for putktlb */
175 
176 	uintptr	stack[1];
177 };
178 
179 struct KMap
180 {
181 	Ref;
182 	u64int	virt;
183 	u64int	phys0;
184 	u64int	phys1;
185 	KMap*	next;
186 	KMap*	konmach[MAXMACH];
187 	Page*	pg;
188 	uintptr	pc;			/* of caller to kmap() */
189 };
190 
191 #define	VA(k)		((k)->virt)
192 #define PPN(x)		((uintptr)(x)>>6)		/* PPN in TLBPHYS0-1 */
193 
194 /* offsets known by l.s */
195 struct Softtlb
196 {
197 	u64int	virt;
198 	u64int	phys0;
199 	u64int	phys1;
200 };
201 
202 struct
203 {
204 	Lock;
205 	long	machs;		/* bitmap of processors */
206 	short	exiting;
207 	int	ispanic;
208 } active;
209 
210 extern KMap kpte[];
211 extern register Mach	*m;
212 extern register Proc	*up;
213 
214 extern FPsave initfp;
215 extern ulong memsize;
216 
217 extern int normalprint;
218 
219 /*
220  *  a parsed plan9.ini line
221  */
222 #define NISAOPT		8
223 
224 struct ISAConf {
225 	char	*type;
226 	ulong	port;
227 	int	irq;
228 	ulong	dma;
229 	ulong	mem;
230 	ulong	size;
231 	ulong	freq;
232 
233 	int	nopt;
234 	char	*opt[NISAOPT];
235 };
236 
237 typedef struct {
238 	ulong	port;
239 	int	size;
240 } Devport;
241 
242 struct DevConf
243 {
244 	ulong	intnum;			/* interrupt number */
245 	char	*type;			/* card type, malloced */
246 	int		nports;			/* Number of ports */
247 	Devport	*ports;			/* The ports themselves */
248 };
249 
250 typedef vlong regint;		/* register sized int, ensure single instr'n */
251