]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/bitsy/dat.h
merge
[plan9front.git] / sys / src / 9 / bitsy / dat.h
1 typedef struct Cisdat           Cisdat;
2 typedef struct Conf             Conf;
3 typedef struct Confmem  Confmem;
4 typedef struct FPU              FPU;
5 typedef struct FPenv            FPenv;
6 typedef struct FPsave           FPsave;
7 typedef struct DevConf          DevConf;
8 typedef struct Label            Label;
9 typedef struct Lock             Lock;
10 typedef struct MMU              MMU;
11 typedef struct Mach             Mach;
12 typedef struct Notsave          Notsave;
13 typedef struct Page             Page;
14 typedef struct PCMmap           PCMmap;
15 typedef struct PCMslot          PCMslot;
16 typedef struct PCMconftab       PCMconftab;
17 typedef struct PhysUart         PhysUart;
18 typedef struct PMMU             PMMU;
19 typedef struct Proc             Proc;
20 typedef struct Uart             Uart;
21 typedef struct Ureg             Ureg;
22 typedef struct Vctl             Vctl;
23 typedef long            Tval;
24
25 #pragma incomplete Ureg
26
27 typedef void IntrHandler(Ureg*, void*);
28
29 #define MAXSYSARG       5       /* for mount(fd, mpt, flag, arg, srv) */
30
31 /*
32  *  parameters for sysproc.c
33  */
34 #define AOUT_MAGIC      (E_MAGIC)
35
36 struct Lock
37 {
38         ulong   key;
39         ulong   sr;
40         ulong   pc;
41         Proc    *p;
42         Mach    *m;
43         ushort  isilock;
44 };
45
46 struct Label
47 {
48         ulong   sp;
49         ulong   pc;
50 };
51
52 /*
53  * FPsave.status
54  */
55 enum
56 {
57         FPinit,
58         FPactive,
59         FPinactive,
60 };
61 struct  FPsave
62 {
63         ulong   status;
64         ulong   control;
65         ulong   regs[8][3];     /* emulated fp */       
66 };
67
68 struct Confmem
69 {
70         ulong   base;
71         ulong   npage;
72         ulong   limit;
73         ulong   kbase;
74         ulong   klimit;
75 };
76
77 struct Conf
78 {
79         ulong   nmach;          /* processors */
80         ulong   nproc;          /* processes */
81         Confmem mem[2];
82         ulong   npage;          /* total physical pages of memory */
83         ulong   upages;         /* user page pool */
84         ulong   nimage;         /* number of page cache image headers */
85         ulong   nswap;          /* number of swap pages */
86         int     nswppo;         /* max # of pageouts per segment pass */
87         ulong   copymode;       /* 0 is copy on write, 1 is copy on reference */
88         int     monitor;
89         ulong   ialloc;         /* bytes available for interrupt time allocation */
90         ulong   pipeqsize;      /* size in bytes of pipe queues */
91         ulong   hz;             /* processor cycle freq */
92         ulong   mhz;
93 };
94
95 /*
96  *  MMU stuff in proc
97  */
98 enum
99 {
100         NCOLOR= 1,      /* 1 level cache, don't worry about VCE's */
101         Nmeg=   32,     /* maximum size of user space */
102 };
103
104 struct PMMU
105 {
106         Page    *l1page[Nmeg];  /* this's process' level 1 entries */
107         ulong   l1table[Nmeg];  /* ... */
108         Page    *mmufree;       /* free mmu pages */
109 };
110
111 /*
112  *  things saved in the Proc structure during a notify
113  */
114 struct Notsave
115 {
116         int dummy;
117 };
118
119 #include "../port/portdat.h"
120
121 struct Mach
122 {
123         int     machno;                 /* physical id of processor */
124         ulong   splpc;                  /* pc of last caller to splhi */
125
126         Proc    *proc;                  /* current process */
127         ulong   mmupid;                 /* process id currently in mmu & cache */
128
129         ulong   ticks;                  /* of the clock since boot time */
130         Label   sched;                  /* scheduler wakeup */
131         Lock    alarmlock;              /* access to alarm list */
132         void*   alarm;                  /* alarms bound to this clock */
133         int     inclockintr;
134
135         Proc*   readied;                /* for runproc */
136         ulong   schedticks;     /* next forced context switch */
137
138         /* stats */
139         int     tlbfault;
140         int     tlbpurge;
141         int     pfault;
142         int     cs;
143         int     syscall;
144         int     load;
145         int     intr;
146         vlong   fastclock;              /* last sampled value */
147         uvlong  inidle;                 /* time spent in idlehands() */
148         ulong   spuriousintr;
149         int     lastintr;
150         int     ilockdepth;
151         Perf    perf;                   /* performance counters */
152
153         int     flushmmu;               /* make current proc flush it's mmu state */
154         Proc    *pid2proc[31];          /* what proc holds what pid */
155         int     lastpid;                /* highest assigned pid slot */
156
157         int     cpumhz;                 /* speed of cpu */
158         vlong   cpuhz;                  /* ... */
159         uvlong  cyclefreq;              /* Frequency of user readable cycle counter */
160
161         /* save areas for exceptions */
162         ulong   sfiq[5];
163         ulong   sirq[5];
164         ulong   sund[5];
165         ulong   sabt[5];
166
167         int     stack[1];
168 };
169
170 /*
171  * Fake kmap since we direct map dram
172  */
173 typedef void            KMap;
174 #define VA(k)           ((ulong)(k))
175 #define kmap(p)         (KMap*)((p)->pa)
176 #define kunmap(k)
177
178 struct
179 {
180         Lock;
181         int     machs;                  /* bitmap of active CPUs */
182         int     exiting;                /* shutdown */
183         int     ispanic;                /* shutdown in response to a panic */
184 }active;
185
186 #define MACHP(n)        ((Mach *)(MACHADDR+(n)*BY2PG))
187
188 extern Mach     *m;
189 extern Proc     *up;
190
191 enum
192 {
193         OneMeg= 1024*1024,
194 };
195
196 /*
197  * PCMCIA structures known by both port/cis.c and the pcmcia driver
198  */
199
200 /*
201  * Map between ISA memory space and PCMCIA card memory space.
202  */
203 struct PCMmap {
204         ulong   ca;                     /* card address */
205         ulong   cea;                    /* card end address */
206         ulong   isa;                    /* local virtual address */
207         int     len;                    /* length of the ISA area */
208         int     attr;                   /* attribute memory */
209 };
210
211 /*
212  *  a PCMCIA configuration entry
213  */
214 struct PCMconftab
215 {
216         int     index;
217         ushort  irqs;           /* legal irqs */
218         uchar   irqtype;
219         uchar   bit16;          /* true for 16 bit access */
220         struct {
221                 ulong   start;
222                 ulong   len;
223         } io[16];
224         int     nio;
225         uchar   vpp1;
226         uchar   vpp2;
227         uchar   memwait;
228         ulong   maxwait;
229         ulong   readywait;
230         ulong   otherwait;
231 };
232
233 /*
234  *  PCMCIA card slot
235  */
236 struct PCMslot
237 {
238         RWlock;
239
240         Ref     ref;
241
242         long    memlen;         /* memory length */
243         uchar   slotno;         /* slot number */
244         void    *regs;          /* i/o registers */
245         void    *mem;           /* memory */
246         void    *attr;          /* attribute memory */
247
248         /* status */
249         uchar   occupied;       /* card in the slot */
250         uchar   configed;       /* card configured */
251         uchar   inserted;       /* card just inserted */
252
253         Dev             *dev;   /* set in ctlwrite `configure' */
254
255         /* cis info */
256         int     cisread;        /* set when the cis has been read */
257         char    verstr[512];    /* version string */
258         int     ncfg;           /* number of configurations */
259         struct {
260                 ushort  cpresent;       /* config registers present */
261                 ulong   caddr;          /* relative address of config registers */
262         } cfg[8];
263         int     nctab;          /* number of config table entries */
264         PCMconftab      ctab[8];
265         PCMconftab      *def;           /* default conftab */
266
267         /* maps are fixed */
268         PCMmap memmap;
269         PCMmap attrmap;
270 };
271
272 /*
273  *  hardware info about a device
274  */
275 typedef struct {
276         ulong   port;   
277         int     size;
278 } Devport;
279
280 struct DevConf
281 {
282         RWlock;                 /* write: configure/unconfigure/suspend; read: normal access */
283         ulong   mem;            /* mapped memory address */
284         Devport *ports;         /* ports[0]: mapped i/o regs, access size */
285         int     nports;         /* always 1 for the bitsy */
286         int     itype;          /* type of interrupt */
287         ulong   intnum;         /* interrupt number */
288         char    *type;          /* card type, mallocated */
289 };
290