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