|
|
1.1 root 1:
2: /* autoconf.c 4.31 81/07/05 */
3: /* Tahoe version, 1/13/83 */
4:
5: /*
6: * Setup the system to run on the current machine.
7: *
8: * Configure() is called at boot time and initializes the vba
9: * device tables and the memory controller monitoring. Available
10: * devices are determined (from possibilities mentioned in ioconf.c),
11: * and the drivers are initialized.
12: *
13: */
14:
15: #include "../machine/pte.h"
16: #include "../h/param.h"
17: #include "../h/systm.h"
18: #include "../h/map.h"
19: #include "../h/buf.h"
20: #include "../h/dk.h"
21: #include "../h/vm.h"
22: #include "../h/conf.h"
23: #include "../h/dmap.h"
24: #include "../machine/mem.h"
25: #include "../machine/mtpr.h"
26: #include "../vba/vbavar.h"
27:
28: /*
29: * The following several variables are related to
30: * the configuration process, and are used in initializing
31: * the machine.
32: */
33:
34: /*
35: * Determine mass storage configuration for a machine.
36: */
37: configure()
38: {
39: register int *ip;
40: extern char Sysbase[];
41:
42: unifind((char *)vmem,(struct pte *)VMEMmap);
43: /*
44: * Write protect the scb. It is strange
45: * that this code is here, but this is as soon
46: * as we are done mucking with it, and the
47: * write-enable was done in assembly language
48: * to which we will never return.
49: */
50: ip = (int *)&Sysmap[2]; *ip &= ~PG_PROT; *ip |= PG_KR;
51: mtpr(Sysbase+0x800, TBIS);
52: #if GENERIC
53: setconf();
54: #endif
55: swapconf();
56: }
57:
58:
59: /*
60: * Make the controllers accessible at physical address phys
61: * by mapping kernel ptes starting at pte.
62: */
63:
64: ioaccess(pte,iobase,iosize)
65: register struct pte *pte;
66: register caddr_t iobase;
67: register int iosize;
68: {
69: register int i = iosize; /* number of ptes to map */
70: register unsigned v = btop(iobase);
71:
72: do
73: *(int *)pte++ = PG_V|PG_KW|v++;
74: while (--i > 0);
75: mtpr(0, TBIA);
76: }
77:
78:
79: /*
80: * Find devices on the BUS.
81: * Uses per-driver routine to see who is on the bus
82: * and then fills in the tables, with help from a per-driver
83: * slave initialization routine.
84: */
85:
86: int iospace_mapped = 0;
87:
88: unifind(vumem, memmap)
89: char *vumem;
90: struct pte *memmap;
91: {
92: register struct vba_device *ui;
93: register struct vba_ctlr *um;
94: u_short *reg;
95: long addr;
96: struct vba_driver *udp;
97: int i;
98:
99: /*
100: * Make the controllers accessible at physical address phys
101: * by mapping kernel ptes starting at pte.
102: */
103: ioaccess(memmap,IOBASE,IOSIZE);
104: iospace_mapped = 1;
105: #define vbaddr(off) (u_short *)((int)vumem + ((off) & 0x0fffff))
106:
107:
108: /*
109: * Check each unibus mass storage controller.
110: * For each one which is potentially on this vba,
111: * see if it is really there, and if it is record it and
112: * then go looking for slaves.
113: */
114: printf("\nControllers found : \n\n");
115: for (um = vbminit; udp = um->um_driver; um++) {
116: if (um->um_vbanum != numvba && um->um_vbanum != '?')
117: continue;
118: addr = (long)um->um_addr;
119: reg = vbaddr(addr);
120: i = (*udp->ud_probe)(reg);
121: if (i == 0)
122: continue;
123: printf("%s%d at vba address %x \n",
124: udp->ud_mname, um->um_ctlr, addr);
125: um->um_alive = 1;
126: um->um_vbanum = numvba;
127: um->um_addr = (caddr_t)reg;
128: udp->ud_minfo[um->um_ctlr] = um;
129: for (ui = vbdinit; ui->ui_driver; ui++) {
130: if (ui->ui_driver != udp || ui->ui_alive ||
131: ui->ui_ctlr != um->um_ctlr && ui->ui_ctlr != '?' ||
132: ui->ui_vbanum != numvba && ui->ui_vbanum != '?')
133: continue;
134: if ((*udp->ud_slave)(ui, reg)) {
135: ui->ui_alive = 1;
136: ui->ui_ctlr = um->um_ctlr;
137: ui->ui_vbanum = numvba;
138: ui->ui_addr = (caddr_t)reg;
139: ui->ui_physaddr = (caddr_t)IOBASE + (addr&0x0fffff);
140: ui->ui_mi = um;
141: /* ui_type comes from driver */
142: udp->ud_dinfo[ui->ui_unit] = ui;
143: printf("\tDrive %d : %s\n",
144: ui->ui_slave, udp->ud_dname);
145: (*udp->ud_attach)(ui);
146: }
147: }
148: }
149: /*
150: * Now look for non-mass storage peripherals.
151: */
152: for (ui = vbdinit; udp = ui->ui_driver; ui++) {
153: if (ui->ui_vbanum != numvba && ui->ui_vbanum != '?' ||
154: ui->ui_alive || ui->ui_slave != -1)
155: continue;
156: addr = (long)ui->ui_addr;
157: reg = vbaddr(addr);
158: if (badaddr((caddr_t)reg, 2))
159: continue;
160: i = (*udp->ud_probe)(reg);
161: if (i == 0)
162: continue;
163: printf("%s%d at vba address %x \n",
164: ui->ui_driver->ud_dname, ui->ui_unit, addr);
165: ui->ui_alive = 1;
166: ui->ui_vbanum = numvba;
167: ui->ui_addr = (caddr_t)reg;
168: ui->ui_physaddr = (caddr_t)IOBASE + (addr&0x0fffff);
169: /* ui_type comes from driver */
170: udp->ud_dinfo[ui->ui_unit] = ui;
171: (*udp->ud_attach)(ui);
172: }
173: }
174:
175:
176: #define DMMIN 32
177: #define DMMAX 1024
178: #define DMTEXT 1024
179: #define MAXDUMP (8*1024)
180: /*
181: * Configure swap space and related parameters.
182: */
183: swapconf()
184: {
185: register struct swdevt *swp;
1.1.1.2 ! root 186: register int nblks = 0;
1.1 root 187:
1.1.1.2 ! root 188: if (dmmin == 0)
! 189: dmmin = DMMIN;
! 190: if (dmmax == 0)
! 191: dmmax = DMMAX;
! 192: if (dmtext == 0)
! 193: dmtext = DMTEXT;
! 194: if (dmtext > dmmax)
! 195: dmtext = dmmax;
1.1 root 196: for (swp = swdevt; swp->sw_dev; swp++) {
1.1.1.2 ! root 197: if (swp->sw_dev == -1)
! 198: break;
1.1 root 199: if (bdevsw[major(swp->sw_dev)].d_psize)
200: nblks =
201: (*bdevsw[major(swp->sw_dev)].d_psize)(swp->sw_dev);
1.1.1.2 ! root 202: if (swp->sw_nblks == 0 || swp->sw_nblks > nblks) {
1.1 root 203: swp->sw_nblks = nblks;
1.1.1.2 ! root 204: swp->sw_segs = nblks / dmmax;
! 205: }
1.1 root 206: }
207: if (dumplo == 0)
208: dumplo = swdevt[0].sw_nblks - MAXDUMP;
209: if (dumplo < 0)
210: dumplo = 0;
211: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.