|
|
1.1 root 1: typedef struct Conf Conf;
2: typedef struct FController FController;
3: typedef struct FDrive FDrive;
4: typedef struct FPsave FPsave;
5: typedef struct FType FType;
6: typedef struct ISAConf ISAConf;
7: typedef struct Label Label;
8: typedef struct Lock Lock;
9: typedef struct MMU MMU;
10: typedef struct Mach Mach;
11: typedef struct PCArch PCArch;
12: typedef struct PCMmap PCMmap;
13: typedef struct Page Page;
14: typedef struct PMMU PMMU;
15: typedef struct Segdesc Segdesc;
16: typedef struct Ureg Ureg;
17: typedef struct User User;
18:
19: #define MACHP(n) (n==0? &mach0 : *(Mach**)0)
20:
21: extern Mach mach0;
22: extern void (*kprofp)(ulong);
23:
24: /*
25: * parameters for sysproc.c
26: */
27: #define AOUT_MAGIC I_MAGIC
28:
29: struct Lock
30: {
31: ulong key;
32: ulong pc;
33: ulong sr;
34: };
35:
36: struct Label
37: {
38: ulong sp;
39: ulong pc;
40: };
41:
42:
43: /*
44: * FPsave.status
45: */
46: enum
47: {
48: FPinit,
49: FPactive,
50: FPinactive,
51: };
52:
53: struct FPsave
54: {
55: ushort control;
56: ushort r1;
57: ushort status;
58: ushort r2;
59: ushort tag;
60: ushort r3;
61: ulong pc;
62: ushort selector;
63: ushort r4;
64: ulong operand;
65: ushort oselector;
66: ushort r5;
67: uchar regs[80]; /* floating point registers */
68: };
69:
70: struct Conf
71: {
72: ulong nmach; /* processors */
73: ulong nproc; /* processes */
74: ulong monitor; /* has monitor? */
75: ulong npage0; /* total physical pages of memory */
76: ulong npage1; /* total physical pages of memory */
77: ulong topofmem; /* highest physical address + 1 */
78: ulong npage; /* total physical pages of memory */
79: ulong upages; /* user page pool */
80: ulong nimage; /* number of page cache image headers */
81: ulong nswap; /* number of swap pages */
82: ulong base0; /* base of bank 0 */
83: ulong base1; /* base of bank 1 */
84: ulong copymode; /* 0 is copy on write, 1 is copy on reference */
85: ulong nfloppy; /* number of floppy drives */
86: ulong nhard; /* number of hard drives */
87: ulong ldepth; /* screen depth */
88: ulong maxx; /* screen width */
89: ulong maxy; /* screen length */
90: };
91:
92: /*
93: * MMU stuff in proc
94: */
95: #define MAXMMU 4
96: #define MAXSMMU 1
97: struct PMMU
98: {
99: Page *mmutop; /* 1st level table */
100: Page *mmufree; /* unused page table pages */
101: Page *mmuused; /* used page table pages */
102: };
103:
104: #include "../port/portdat.h"
105:
106: /*
107: * machine dependent definitions not used by ../port/dat.h
108: */
109:
110: /*
111: * task state segment. Plan 9 ignores all the task switching goo and just
112: * uses the tss for esp0 and ss0 on gate's into the kernel, interrupts,
113: * and exceptions. The rest is completely ignored.
114: *
115: * We use one tss per CPU because we'll need to in Brazil.
116: *
117: */
118: typedef struct Tss Tss;
119: struct Tss
120: {
121: ulong backlink; /* unused */
122: ulong sp0; /* pl0 stack pointer */
123: ulong ss0; /* pl0 stack selector */
124: ulong sp1; /* pl1 stack pointer */
125: ulong ss1; /* pl1 stack selector */
126: ulong sp2; /* pl2 stack pointer */
127: ulong ss2; /* pl2 stack selector */
128: ulong cr3; /* page table descriptor */
129: ulong eip; /* instruction pointer */
130: ulong eflags; /* processor flags */
131: ulong eax; /* general (hah?) registers */
132: ulong ecx;
133: ulong edx;
134: ulong ebx;
135: ulong esp;
136: ulong ebp;
137: ulong esi;
138: ulong edi;
139: ulong es; /* segment selectors */
140: ulong cs;
141: ulong ss;
142: ulong ds;
143: ulong fs;
144: ulong gs;
145: ulong ldt; /* local descriptor table */
146: ulong iomap; /* io map base */
147: };
148:
149: /*
150: * segment descriptor/gate
151: */
152: struct Segdesc
153: {
154: ulong d0;
155: ulong d1;
156: };
157:
158: struct Mach
159: {
160: /* OFFSETS OF THE FOLLOWING KNOWN BY l.s */
161: int machno; /* physical id of processor */
162: ulong splpc; /* pc of last caller to splhi */
163:
164: /* ordering from here on irrelevant */
165: int mmask; /* 1<<m->machno */
166: ulong ticks; /* of the clock since boot time */
167: Proc *proc; /* current process on this processor */
168: Label sched; /* scheduler wakeup */
169: Lock alarmlock; /* access to alarm list */
170: void *alarm; /* alarms bound to this clock */
171:
172: int tlbfault;
173: int tlbpurge;
174: int pfault;
175: int cs;
176: int syscall;
177: int load;
178: int intr;
179:
180: Tss tss;
181: Segdesc gdt[N386SEG];
182:
183: int stack[1];
184: };
185:
186: /*
187: * Fake kmap
188: */
189: typedef void KMap;
190: #define VA(k) ((ulong)(k))
191: #define kmap(p) (KMap*)((p)->pa|KZERO)
192: #define kunmap(k)
193:
194: #define NERR 15
195: #define NNOTE 5
196: struct User
197: {
198: Proc *p;
199: FPsave fpsave; /* address of this is known by vdb */
200: int scallnr; /* sys call number - known by db */
201: Sargs s; /* address of this is known by db */
202: int nerrlab;
203: Label errlab[NERR];
204: char error[ERRLEN];
205: char elem[NAMELEN]; /* last name element from namec */
206: Chan *slash;
207: Chan *dot;
208: /*
209: * Rest of structure controlled by devproc.c and friends.
210: * lock(&p->debug) to modify.
211: */
212: Note note[NNOTE];
213: short nnote;
214: short notified; /* sysnoted is due */
215: Note lastnote;
216: int (*notify)(void*, char*);
217: void *ureg;
218: void *dbgreg; /* User registers for debugging in proc */
219: ulong svcs; /* cs before a notify */
220: ulong svss; /* ss before a notify */
221: ulong svflags; /* flags before a notify */
222: };
223:
224: struct
225: {
226: Lock;
227: short machs;
228: short exiting;
229: }active;
230:
231: /*
232: * routines for things outside the PC model, like power management
233: */
234: struct PCArch
235: {
236: char *id;
237: void (*reset)(void); /* this should be in the model */
238: int (*cpuspeed)(int); /* 0 = low, 1 = high */
239: void (*buzz)(int, int); /* make a noise */
240: void (*lights)(int); /* turn lights or icons on/off */
241: int (*serialpower)(int); /* 1 == on, 0 == off */
242: int (*modempower)(int); /* 1 == on, 0 == off */
243: int (*extvga)(int); /* 1 == external, 0 == internal */
244: int (*snooze)(ulong, int);
245: };
246:
247: extern Mach *m;
248: extern User *u;
249:
250: ulong boottime;
251:
252: extern int flipD[]; /* for flipping bitblt destination polarity */
253:
254: #define BOOTLINE ((char *)0x80000100) /* bootline passed by boot program */
255:
256: extern PCArch *arch; /* PC architecture */
257:
258: struct ISAConf {
259: char type[NAMELEN];
260: ulong port;
261: ulong irq;
262: int dma;
263: ulong mem;
264: ulong size;
265: uchar ea[6];
266: uchar bus;
267: };
268:
269: /*
270: * maps between ISA memory space and PCMCIA card memory space
271: */
272: struct PCMmap
273: {
274: ulong ca; /* card address */
275: ulong cea; /* card end address */
276: ulong isa; /* ISA address */
277: int len; /* length of the ISA area */
278: int attr; /* attribute memory */
279: int ref;
280: };
281:
282: /*
283: * a floppy drive
284: */
285: struct FDrive
286: {
287: FType *t; /* floppy type */
288: int dt; /* drive type */
289: int dev;
290:
291: ulong lasttouched; /* time last touched */
292: int cyl; /* current arm position */
293: int confused; /* needs to be recalibrated */
294: int vers;
295:
296: int tcyl; /* target cylinder */
297: int thead; /* target head */
298: int tsec; /* target sector */
299: long len; /* size of xfer */
300:
301: uchar *cache; /* track cache */
302: int ccyl;
303: int chead;
304:
305: Rendez r; /* waiting here for motor to spin up */
306: };
307:
308: /*
309: * controller for 4 floppys
310: */
311: struct FController
312: {
313: QLock; /* exclusive access to the contoller */
314:
315: FDrive *d; /* the floppy drives */
316: FDrive *selected;
317: int rate; /* current rate selected */
318: uchar cmd[14]; /* command */
319: int ncmd; /* # command bytes */
320: uchar stat[14]; /* command status */
321: int nstat; /* # status bytes */
322: int confused; /* controler needs to be reset */
323: Rendez r; /* wait here for command termination */
324: int motor; /* bit mask of spinning disks */
325: Rendez kr; /* for motor watcher */
326: };
327:
328: /*
329: * floppy types (all MFM encoding)
330: */
331: struct FType
332: {
333: char *name;
334: int dt; /* compatible drive type */
335: int bytes; /* bytes/sector */
336: int sectors; /* sectors/track */
337: int heads; /* number of heads */
338: int steps; /* steps per cylinder */
339: int tracks; /* tracks/disk */
340: int gpl; /* intersector gap length for read/write */
341: int fgpl; /* intersector gap length for format */
342: int rate; /* rate code */
343:
344: /*
345: * these depend on previous entries and are set filled in
346: * by floppyinit
347: */
348: int bcode; /* coded version of bytes for the controller */
349: long cap; /* drive capacity in bytes */
350: long tsize; /* track size in bytes */
351: };
352: /* bits in the registers */
353: enum
354: {
355: /* status registers a & b */
356: Psra= 0x3f0,
357: Psrb= 0x3f1,
358:
359: /* digital output register */
360: Pdor= 0x3f2,
361: Fintena= 0x8, /* enable floppy interrupt */
362: Fena= 0x4, /* 0 == reset controller */
363:
364: /* main status register */
365: Pmsr= 0x3f4,
366: Fready= 0x80, /* ready to be touched */
367: Ffrom= 0x40, /* data from controller */
368: Ffloppybusy= 0x10, /* operation not over */
369:
370: /* data register */
371: Pfdata= 0x3f5,
372: Frecal= 0x07, /* recalibrate cmd */
373: Fseek= 0x0f, /* seek cmd */
374: Fsense= 0x08, /* sense cmd */
375: Fread= 0x66, /* read cmd */
376: Freadid= 0x4a, /* read track id */
377: Fspec= 0x03, /* set hold times */
378: Fwrite= 0x45, /* write cmd */
379: Fformat= 0x4d, /* format cmd */
380: Fmulti= 0x80, /* or'd with Fread or Fwrite for multi-head */
381: Fdumpreg= 0x0e, /* dump internal registers */
382:
383: /* digital input register */
384: Pdir= 0x3F7, /* disk changed port (read only) */
385: Pdsr= 0x3F7, /* data rate select port (write only) */
386: Fchange= 0x80, /* disk has changed */
387:
388: /* status 0 byte */
389: Drivemask= 3<<0,
390: Seekend= 1<<5,
391: Codemask= (3<<6)|(3<<3),
392: };
393:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.