]> git.lizzy.rs Git - plan9front.git/blob - sys/src/9/alphapc/dat.h
etheriwl: implement 4965 firmware bootstrap (untested)
[plan9front.git] / sys / src / 9 / alphapc / dat.h
1 typedef struct Conf     Conf;
2 typedef struct Confmem  Confmem;
3 typedef struct FPsave   FPsave;
4 typedef struct ISAConf  ISAConf;
5 typedef struct Label    Label;
6 typedef struct Lock     Lock;
7 typedef struct Mach     Mach;
8 typedef struct Notsave  Notsave;
9 typedef struct Page     Page;
10 typedef struct PCArch   PCArch;
11 typedef struct PCB      PCB;
12 typedef struct Pcidev   Pcidev;
13 typedef struct PMMU     PMMU;
14 typedef struct Proc     Proc;
15 typedef struct Sys      Sys;
16 typedef struct Ureg     Ureg;
17 typedef struct Vctl     Vctl;
18 typedef vlong           Tval;
19
20 #define MAXSYSARG       6       /* for mount(fd, mpt, flag, arg, srv) */
21
22 /*
23  *  parameters for sysproc.c
24  */
25 #define AOUT_MAGIC      L_MAGIC
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         ulong   pid;
39         ushort  isilock;
40 };
41
42 struct Label
43 {
44         ulong   sp;
45         ulong   pc;
46 };
47
48 /*
49  * Proc.fpstate
50  */
51 enum
52 {
53         /* floating point states */
54         FPinit,
55         FPactive,
56         FPinactive,
57
58         /* bit or'd with the state */
59         FPillegal= 0x100,
60 };
61
62 struct  FPsave
63 {
64         long    fpreg[2*32];
65         long    dummy;          /* lower bits of FPCR, useless */
66         long    fpstatus;
67 };
68
69 struct Confmem
70 {
71         ulong   base;
72         ulong   npage;
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;                /* has display? */
89         ulong   ialloc;         /* bytes available for interrupt time allocation */
90         ulong   pipeqsize;      /* size in bytes of pipe queues */
91 };
92
93 /*
94  *  mmu goo in the Proc structure
95  */
96 struct PMMU
97 {
98         Page    *mmutop;        /* 1st level table */
99         Page    *mmulvl2;       /* 2nd level table */
100         Page    *mmufree;       /* unused page table pages */
101         Page    *mmuused;       /* used page table pages, except for mmustk */
102 };
103
104 /*
105  *  things saved in the Proc structure during a notify
106  */
107 struct Notsave
108 {
109         ulong   UNUSED;
110 };
111
112 #include "../port/portdat.h"
113
114 /*
115  *  machine dependent definitions not used by ../port/dat.h
116  */
117 /*
118  * Fake kmap
119  */
120 typedef void            KMap;
121 #define VA(k)           ((ulong)(k))
122 #define kmap(p)         (KMap*)((p)->pa|KZERO)
123 #define kunmap(k)
124
125 /*
126  *      Process Control Block, used by PALcode
127  */
128 struct PCB {
129         uvlong  ksp;
130         uvlong  usp;
131         uvlong  ptbr;
132         ulong   asn;
133         ulong   pcc;
134         uvlong  unique;
135         ulong   fen;
136         ulong   dummy;
137         uvlong  rsrv1;
138         uvlong  rsrv2;
139 };
140
141 struct Mach
142 {
143         /* OFFSETS OF THE FOLLOWING KNOWN BY l.s */
144         int     machno;                 /* physical id of processor */
145         ulong   splpc;                  /* pc that called splhi() */
146         Proc    *proc;                  /* current process on this processor */
147
148         /* ordering from here on irrelevant */
149
150         ulong   ticks;                  /* of the clock since boot time */
151         Label   sched;                  /* scheduler wakeup */
152         Lock    alarmlock;              /* access to alarm list */
153         void    *alarm;                 /* alarms bound to this clock */
154         int     inclockintr;
155
156         Proc*   readied;                /* for runproc */
157         ulong   schedticks;     /* next forced context switch */
158
159         vlong   cpuhz;                  /* hwrpb->cfreq */
160         uvlong  cyclefreq;              /* Frequency of user readable cycle counter */
161         ulong   pcclast;
162         uvlong  fastclock;
163         Perf    perf;                   /* performance counters */
164
165         int     tlbfault;               /* only used by devproc; no access to tlb */
166         int     tlbpurge;               /* ... */
167         int     pfault;
168         int     cs;
169         int     syscall;
170         int     load;
171         int     intr;
172         int     flushmmu;               /* make current proc flush it's mmu state */
173         int     ilockdepth;
174
175         ulong   spuriousintr;
176         int     lastintr;
177
178         PCB;
179
180         /* MUST BE LAST */
181         int     stack[1];
182 };
183
184 struct
185 {
186         Lock;
187         short   machs;
188         short   exiting;
189         short   ispanic;
190 }active;
191
192 /*
193  *      Implementation-dependant functions (outside of Alpha architecture proper).
194  *      Called PCArch because that's what mkdevc calls it (for the PC).
195  */
196 struct PCArch
197 {
198         char*   id;
199         int     (*ident)(void);
200
201         void    (*coreinit)(void);              /* set up core logic, PCI mappings etc */
202         void    (*corehello)(void);             /* identify core logic to user */
203         void    (*coredetach)(void);            /* restore core logic before return to console */
204         void    *(*pcicfg)(int, int);           /* map and point to PCI cfg space */
205         void    *(*pcimem)(int, int);           /* map and point to PCI memory space */
206         int     (*intrenable)(Vctl*);
207         int     (*intrvecno)(int);
208         int     (*intrdisable)(int);
209
210         int     (*_inb)(int);
211         ushort  (*_ins)(int);
212         ulong   (*_inl)(int);
213         void    (*_outb)(int, int);
214         void    (*_outs)(int, ushort);
215         void    (*_outl)(int, ulong);
216         void    (*_insb)(int, void*, int);
217         void    (*_inss)(int, void*, int);
218         void    (*_insl)(int, void*, int);
219         void    (*_outsb)(int, void*, int);
220         void    (*_outss)(int, void*, int);
221         void    (*_outsl)(int, void*, int);
222 };
223
224 /*
225  *  a parsed plan9.ini line
226  */
227 #define NISAOPT         8
228
229 struct ISAConf {
230         char    *type;
231         ulong   port;
232         int     irq;
233         ulong   dma;
234         ulong   mem;
235         ulong   size;
236         ulong   freq;
237
238         int     nopt;
239         char    *opt[NISAOPT];
240 };
241
242 extern PCArch   *arch;
243
244 #define MACHP(n)        ((Mach *)((int)&mach0+n*BY2PG))
245 extern Mach             mach0;
246
247 extern register Mach    *m;
248 extern register Proc    *up;
249
250 /*
251  *  hardware info about a device
252  */
253 typedef struct {
254         ulong   port;   
255         int     size;
256 } Devport;
257
258 struct DevConf
259 {
260         ulong   intnum; /* interrupt number */
261         char    *type;  /* card type, malloced */
262         int     nports; /* Number of ports */
263         Devport *ports; /* The ports themselves */
264 };
265
266 extern FPsave initfp;