|
|
1.1 root 1: #ifdef LOCORE
2: #define P_LINK 0
3: #define P_RLINK 4
4: #define P_ADDR 8
5: #define P_PRI 13
6: #define P_STAT 15
7: #define P_WCHAN 76
8: #define SSLEEP 1
9: #define SRUN 3
10: #define UBA_BRRVR 48
11: #define UH_UBA 0
12: #define UH_VEC 8
13: #define UH_SIZE 52
14: #define RP_FLAG 12
15: #define V_SWTCH 0
16: #define V_TRAP 4
17: #define V_SYSCALL 8
18: #define V_INTR 12
19: #define V_PDMA 16
20: #define UPAGES 8
21: #define CLSIZE 2
22: #define SYSPTSIZE 1536
23: #define USRPTSIZE 1024
24: #else
25: asm(".set U_ARG,120");
26: asm(".set U_QSAV,140");
27: #endif
28: /* scb.s 4.9 81/05/13 */
29:
30: /*
31: * System control block
32: */
33: .set INTSTK,1 # handle this interrupt on the interrupt stack
34: .set HALT,3 # halt if this interrupt occurs
35:
36: _scb: .globl _scb
37:
38: #define STRAY .long _Xstray+INTSTK
39: #define STRAY8 STRAY;STRAY;STRAY;STRAY;STRAY;STRAY;STRAY;STRAY
40: #define STRAY15 STRAY;STRAY;STRAY;STRAY;STRAY;STRAY;STRAY;STRAY8
41: #define KS(a) .long _X/**/a
42: #define IS(a) .long _X/**/a+INTSTK
43: #define STOP(a) .long _X/**/a+HALT
44:
45: /* 000 */ STRAY; IS(machcheck); IS(kspnotval); STOP(powfail);
46: /* 010 */ KS(privinflt); KS(xfcflt); KS(resopflt); KS(resadflt);
47: /* 020 */ KS(protflt); KS(transflt); KS(tracep); KS(bptflt);
48: /* 030 */ KS(compatflt); KS(arithtrap); STRAY; STRAY;
49: /* 040 */ KS(syscall); KS(chme); KS(chms); KS(chmu);
50: /* 050 */ STRAY; IS(cmrd); STRAY; STRAY;
51: /* 060 */ IS(wtime); STRAY; STRAY; STRAY;
52: /* 070 */ STRAY; STRAY; STRAY; STRAY;
53: /* 080 */ STRAY; STRAY; KS(astflt); STRAY;
54: /* 090 */ STRAY; STRAY; STRAY; STRAY;
55: /* 0a0 */ IS(softclock); STRAY; STRAY; STRAY;
56: /* 0b0 */ STRAY; STRAY; STRAY; STRAY;
57: /* 0c0 */ IS(hardclock); STRAY; STRAY; STRAY;
58: /* 0d0 */ STRAY; STRAY; STRAY; STRAY;
59: /* 0e0 */ STRAY; STRAY; STRAY; STRAY;
60: /* 0f0 */ IS(consdin); IS(consdout); IS(cnrint); IS(cnxint);
61: /* 100 */ IS(nexzvec); STRAY15; /* ipl 0x14, nexus 0-15 */
62: /* 140 */ IS(nexzvec); STRAY15; /* ipl 0x15, nexus 0-15 */
63: /* 180 */ IS(nexzvec); STRAY15; /* ipl 0x16, nexus 0-15 */
64: /* 1c0 */ IS(nexzvec); STRAY15; /* ipl 0x17, nexus 0-15 */
65:
66: .globl _UNIvec
67: _UNIvec: .space 512 # 750 unibus intr vector
68: # 1st UBA jump table on 780's
69: /* locore.s 4.55- 82/02/17 */
70:
71: #include "../h/mtpr.h"
72: #include "../h/trap.h"
73: #include "../h/psl.h"
74: #include "../h/pte.h"
75: #include "../h/cpu.h"
76: #include "../h/nexus.h"
77: #include "../h/ubareg.h"
78:
79: #include "dz.h"
80: #include "mba.h"
81:
82: .set HIGH,0x1f # mask for total disable
83: .set MCKVEC,4 # offset into scb of machine check vector
84: .set NBPG,512
85: .set PGSHIFT,9
86:
87: .set NISP,3 # number of interrupt stack pages
88:
89: /*
90: * User structure is UPAGES at top of user space.
91: */
92: .globl _u
93: .set _u,0x80000000 - UPAGES*NBPG
94:
95: /*
96: * Restart parameter block
97: * This is filled in in machdep.c in startup().
98: * It MUST be page aligned.
99: * When auto-restart occurs, we run restart() in machdep.c, which
100: * takes a core-dump and then cold-starts.
101: */
102: .globl _rpb
103: _rpb:
104: .space 508
105: erpb:
106: .space 4
107: .globl _intstack
108: _intstack:
109: .space NISP*NBPG
110: eintstack:
111:
112: /*
113: * Do a dump.
114: * Called by auto-restart.
115: * May be called manually.
116: */
117: .align 2
118: .globl _doadump
119: _doadump:
120: nop; nop # .word 0x0101
121: #define _rpbmap _Sysmap+8 # scb, UNIvec, rpb, istack*4
122: bicl2 $PG_PROT,_rpbmap
123: bisl2 $PG_KW,_rpbmap
124: tstl _rpb+RP_FLAG # dump only once!
125: bneq 1f
126: incl _rpb+RP_FLAG
127: mtpr $0,$TBIA
128: movl sp,erpb
129: movab erpb,sp
130: mfpr $PCBB,-(sp)
131: mfpr $MAPEN,-(sp)
132: mfpr $IPL,-(sp)
133: mtpr $0,$MAPEN
134: mtpr $HIGH,$IPL
135: pushr $0x3fff
136: calls $0,_dumpsys
137: 1:
138: halt
139:
140: /*
141: * Interrupt vector routines
142: */
143: .globl _waittime
144:
145: #define SCBVEC(name) .align 2; .globl _X/**/name; _X/**/name
146: #define PANIC(msg) clrl _waittime; pushab 1f; \
147: calls $1,_panic; 1: .asciz msg
148: #define PRINTF(n,msg) pushab 1f; calls $n+1,_printf; MSG(msg)
149: #define MSG(msg) .data; 1: .asciz msg; .text
150: #define PUSHR pushr $0x3f
151: #define POPR popr $0x3f
152:
153: SCBVEC(machcheck):
154: PUSHR; pushab 6*4(sp); calls $1,_machinecheck; POPR;
155: addl2 (sp)+,sp; rei
156: SCBVEC(kspnotval):
157: PUSHR; PANIC("KSP not valid");
158: SCBVEC(powfail):
159: halt
160: SCBVEC(chme): SCBVEC(chms): SCBVEC(chmu):
161: PUSHR; PANIC("CHM? in kernel");
162: SCBVEC(stray):
163: PUSHR; PRINTF(0, "stray scb interrupt\n"); POPR;
164: rei
165: SCBVEC(nexzvec):
166: PUSHR; mfpr $IPL,-(sp); PRINTF(1, "nexus stray intr ipl%x\n"); POPR; rei
167: SCBVEC(cmrd):
168: PUSHR; calls $0,_memerr; POPR; rei
169: SCBVEC(wtime):
170: PUSHR; pushl 6*4(sp); PRINTF(1,"write timeout %x\n"); POPR;
171: PANIC("wtimo");
172:
173: #if NMBA > 0
174: SCBVEC(mba3int):
175: PUSHR; pushl $3; brb 1f
176: SCBVEC(mba2int):
177: PUSHR; pushl $2; brb 1f
178: SCBVEC(mba1int):
179: PUSHR; pushl $1; brb 1f
180: SCBVEC(mba0int):
181: PUSHR; pushl $0
182: 1: calls $1,_mbintr
183: POPR
184: incl _cnt+V_INTR
185: rei
186: #endif
187:
188: #if VAX780
189: /*
190: * Registers for the uba handling code
191: */
192: #define rUBANUM r0
193: #define rUBAHD r1
194: #define rUVEC r3
195: #define rUBA r4
196: /* r2,r5 are scratch */
197:
198: SCBVEC(ua3int):
199: PUSHR; movl $3,rUBANUM; moval _uba_hd+(3*UH_SIZE),rUBAHD; brb 1f
200: SCBVEC(ua2int):
201: PUSHR; movl $2,rUBANUM; moval _uba_hd+(2*UH_SIZE),rUBAHD; brb 1f
202: SCBVEC(ua1int):
203: PUSHR; movl $1,rUBANUM; moval _uba_hd+(1*UH_SIZE),rUBAHD; brb 1f
204: SCBVEC(ua0int):
205: PUSHR; movl $0,rUBANUM; moval _uba_hd+(0*UH_SIZE),rUBAHD;
206: 1:
207: incl _cnt+V_INTR
208: mfpr $IPL,r2 /* r2 = mfpr(IPL); */
209: movl UH_UBA(rUBAHD),rUBA /* uba = uhp->uh_uba; */
210: movl UBA_BRRVR-0x14*4(rUBA)[r2],rUVEC
211: /* uvec = uba->uba_brrvr[r2-0x14] */
212: ubanorm:
213: bleq ubaerror
214: addl2 UH_VEC(rUBAHD),rUVEC /* uvec += uh->uh_vec */
215: bicl3 $3,(rUVEC),r1
216: jmp 2(r1) /* 2 skips ``pushr $0x3f'' */
217: ubaerror:
218: PUSHR; calls $0,_ubaerror; POPR /* ubaerror r/w's r0-r5 */
219: tstl rUVEC; jneq ubanorm /* rUVEC contains result */
220: POPR
221: rei
222: #endif
223: SCBVEC(cnrint):
224: PUSHR; calls $0,_cnrint; POPR; incl _cnt+V_INTR; rei
225: SCBVEC(cnxint):
226: PUSHR; calls $0,_cnxint; POPR; incl _cnt+V_INTR; rei
227: SCBVEC(hardclock):
228: PUSHR
229: pushl 4+6*4(sp); pushl 4+6*4(sp);
230: calls $2,_hardclock # hardclock(pc,psl)
231: POPR;
232: incl _cnt+V_INTR ## temp so not to break vmstat -= HZ
233: rei
234: SCBVEC(softclock):
235: PUSHR
236: pushl 4+6*4(sp); pushl 4+6*4(sp);
237: calls $2,_softclock # softclock(pc,psl)
238: POPR;
239: rei
240: #if defined(VAX750) || defined(VAX7ZZ)
241: SCBVEC(consdin):
242: PUSHR; calls $0,_turintr; POPR; incl _cnt+V_INTR; rei
243:
244: SCBVEC(consdout):
245: PUSHR; calls $0,_tuxintr; POPR; incl _cnt+V_INTR; rei
246: #else
247: SCBVEC(consdin):
248: halt
249: SCBVEC(consdout):
250: halt
251: #endif
252:
253: #if NDZ > 0
254: /*
255: * DZ pseudo dma routine:
256: * r0 - controller number
257: */
258: .align 1
259: .globl _dzdma
260: _dzdma:
261: mull2 $8*20,r0
262: movab _dzpdma(r0),r3 # pdma structure base
263: # for this controller
264: dzploop:
265: movl r3,r0
266: movl (r0)+,r1 # device register address
267: movzbl 1(r1),r2 # get line number
268: bitb $0x80,r2 # TRDY on?
269: beql dzprei # no
270: bicb2 $0xf8,r2 # clear garbage bits
271: mull2 $20,r2
272: addl2 r2,r0 # point at line's pdma structure
273: movl (r0)+,r2 # p_mem
274: cmpl r2,(r0)+ # p_mem < p_end ?
275: bgequ dzpcall # no, go call dzxint
276: movb (r2)+,6(r1) # dztbuf = *p_mem++
277: movl r2,-8(r0)
278: brb dzploop # check for another line
279: dzprei:
280: POPR
281: incl _cnt+V_PDMA
282: rei
283:
284: dzpcall:
285: pushl r3
286: pushl (r0)+ # push tty address
287: calls $1,*(r0) # call interrupt rtn
288: movl (sp)+,r3
289: brb dzploop # check for another line
290: #endif
291:
292: /*
293: * Stray UNIBUS interrupt catch routines
294: */
295: .data
296: .align 2
297: #define PJ PUSHR;jsb _Xustray
298: .globl _catcher
299: _catcher:
300: PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ
301: PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ
302: PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ
303: PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ
304: PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ
305: PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ
306: PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ
307: PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ;PJ
308:
309: .globl _cold
310: _cold: .long 1
311: .data
312:
313: .text
314: SCBVEC(ustray):
315: blbc _cold,1f
316: mfpr $IPL,r11
317: subl3 $_catcher+8,(sp)+,r10
318: ashl $-1,r10,r10
319: POPR
320: rei
321: 1:
322: subl3 $_catcher+8,(sp)+,r0
323: ashl $-1,r0,-(sp)
324: mfpr $IPL,-(sp)
325: PRINTF(2, "uba?: stray intr ipl %x vec %o\n")
326: POPR
327: rei
328:
329: /*
330: * Trap and fault vector routines
331: */
332: #define TRAP(a) pushl $a; brw alltraps
333:
334: /*
335: * Ast delivery (profiling and/or reschedule)
336: */
337: SCBVEC(astflt):
338: pushl $0; TRAP(ASTFLT)
339: SCBVEC(privinflt):
340: pushl $0; TRAP(PRIVINFLT)
341: SCBVEC(xfcflt):
342: pushl $0; TRAP(XFCFLT)
343: SCBVEC(resopflt):
344: pushl $0; TRAP(RESOPFLT)
345: SCBVEC(resadflt):
346: pushl $0; TRAP(RESADFLT)
347: SCBVEC(bptflt):
348: pushl $0; TRAP(BPTFLT)
349: SCBVEC(compatflt):
350: TRAP(COMPATFLT);
351: SCBVEC(tracep):
352: pushl $0; TRAP(TRCTRAP)
353: SCBVEC(arithtrap):
354: TRAP(ARITHTRAP)
355: SCBVEC(protflt):
356: blbs (sp)+,segflt
357: TRAP(PROTFLT)
358: segflt:
359: TRAP(SEGFLT)
360: SCBVEC(transflt):
361: bitl $1,(sp)+
362: bnequ tableflt
363: TRAP(PAGEFLT)
364: tableflt:
365: TRAP(TABLEFLT)
366:
367: alltraps:
368: mfpr $USP,-(sp); calls $0,_trap; mtpr (sp)+,$USP
369: incl _cnt+V_TRAP
370: addl2 $8,sp # pop type, code
371: mtpr $HIGH,$IPL ## dont go to a higher IPL (GROT)
372: rei
373:
374: SCBVEC(syscall):
375: pushl $SYSCALL
376: mfpr $USP,-(sp); calls $0,_syscall; mtpr (sp)+,$USP
377: incl _cnt+V_SYSCALL
378: addl2 $8,sp # pop type, code
379: mtpr $HIGH,$IPL ## dont go to a higher IPL (GROT)
380: rei
381:
382: /*
383: * System page table
384: */
385: #define vaddr(x) ((((x)-_Sysmap)/4)*NBPG+0x80000000)
386: #define SYSMAP(mname, vname, npte) \
387: _/**/mname: .globl _/**/mname; \
388: .space npte*4; \
389: .globl _/**/vname; \
390: .set _/**/vname,vaddr(_/**/mname)
391:
392: .data
393: .align 2
394: SYSMAP(Sysmap ,Sysbase ,SYSPTSIZE )
395: SYSMAP(UMBAbeg ,umbabeg ,0 )
396: SYSMAP(Nexmap ,nexus ,16*MAXNNEXUS )
397: SYSMAP(UMEMmap ,umem ,16*MAXNUBA )
398: SYSMAP(UMBAend ,umbaend ,0 )
399: SYSMAP(Usrptmap ,usrpt ,USRPTSIZE )
400: SYSMAP(Forkmap ,forkutl ,UPAGES )
401: SYSMAP(Xswapmap ,xswaputl ,UPAGES )
402: SYSMAP(Xswap2map,xswap2utl ,UPAGES )
403: SYSMAP(Swapmap ,swaputl ,UPAGES )
404: SYSMAP(Pushmap ,pushutl ,UPAGES )
405: SYSMAP(Vfmap ,vfutl ,UPAGES )
406: SYSMAP(CMAP1 ,CADDR1 ,1 )
407: SYSMAP(CMAP2 ,CADDR2 ,1 )
408: SYSMAP(mcrmap ,mcr ,1 )
409: SYSMAP(mmap ,vmmap ,1 )
410: SYSMAP(msgbufmap,msgbuf ,CLSIZE )
411: SYSMAP(camap ,cabase ,16*CLSIZE )
412: SYSMAP(ecamap ,calimit ,0 )
413: #ifdef BBNNET
414: SYSMAP(Netmap ,netutl ,NNETPAGES*CLSIZE)
415: #endif
416:
417: eSysmap:
418: .globl _Syssize
419: .set _Syssize,(eSysmap-_Sysmap)/4
420: .text
421:
422: /*
423: * Initialization
424: *
425: * ipl 0x1f; mapen 0; scbb, pcbb, sbr, slr, isp, ksp not set
426: */
427: .data
428: .globl _cpu
429: _cpu: .long 0
430: .text
431: .globl start
432: start:
433: .word 0
434: /* set system control block base and system page table params */
435: mtpr $_scb-0x80000000,$SCBB
436: mtpr $_Sysmap-0x80000000,$SBR
437: mtpr $_Syssize,$SLR
438: /* double map the kernel into the virtual user addresses of phys mem */
439: mtpr $_Sysmap,$P0BR
440: mtpr $_Syssize,$P0LR
441: /* set ISP and get cpu type */
442: movl $_intstack+NISP*NBPG,sp
443: mfpr $SID,r0
444: movab _cpu,r1
445: extzv $24,$8,r0,(r1)
446: /* init RPB */
447: movab _rpb,r0
448: movl r0,(r0)+ # rp_selfref
449: movab _doadump,r1
450: movl r1,(r0)+ # rp_dumprout
451: movl $0x1f,r2
452: clrl r3
453: 1: addl2 (r1)+,r3; sobgtr r2,1b
454: movl r3,(r0)+ # rp_chksum
455: /* count up memory */
456: clrl r7
457: 1: pushl $4; pushl r7; calls $2,_badaddr; tstl r0; bneq 9f
458: acbl $8096*1024-1,$64*1024,r7,1b
459: 9:
460: /* clear memory from kernel bss and pages for proc 0 u. and page table */
461: movab _edata,r6
462: movab _end,r5
463: bbcc $31,r5,0f; 0:
464: addl2 $(UPAGES*NBPG)+NBPG+NBPG,r5
465: 1: clrq (r6); acbl r5,$8,r6,1b
466: /* trap() and syscall() save r0-r11 in the entry mask (per ../h/reg.h) */
467: bisw2 $0x0fff,_trap
468: bisw2 $0x0fff,_syscall
469: calls $0,_fixctlrmask
470: /* initialize system page table: scb and int stack writeable */
471: clrl r2
472: movab eintstack,r1; bbcc $31,r1,0f; 0: ashl $-PGSHIFT,r1,r1
473: 1: bisl3 $PG_V|PG_KW,r2,_Sysmap[r2]; aoblss r1,r2,1b
474: /* make rpb read-only as red zone for interrupt stack */
475: bicl2 $PG_PROT,_rpbmap
476: bisl2 $PG_KR,_rpbmap
477: /* make kernel text space read-only */
478: movab _etext+NBPG-1,r1; bbcc $31,r1,0f; 0: ashl $-PGSHIFT,r1,r1
479: 1: bisl3 $PG_V|PG_KR,r2,_Sysmap[r2]; aoblss r1,r2,1b
480: /* make kernel data, bss, read-write */
481: movab _end+NBPG-1,r1; bbcc $31,r1,0f; 0:; ashl $-PGSHIFT,r1,r1
482: 1: bisl3 $PG_V|PG_KW,r2,_Sysmap[r2]; aoblss r1,r2,1b
483: /* now go to mapped mode */
484: mtpr $1,$TBIA; mtpr $1,$MAPEN; jmp *$0f; 0:
485: /* init mem sizes */
486: ashl $-PGSHIFT,r7,_maxmem
487: movl _maxmem,_physmem
488: movl _maxmem,_freemem
489: /* setup context for proc[0] == Scheduler */
490: movab _end+NBPG-1,r6
491: bicl2 $NBPG-1,r6 # make page boundary
492: /* setup page table for proc[0] */
493: bbcc $31,r6,0f; 0:
494: ashl $-PGSHIFT,r6,r3 # r3 = btoc(r6)
495: bisl3 $PG_V|PG_KW,r3,_Usrptmap # init first upt entry
496: incl r3
497: movab _usrpt,r0
498: mtpr r0,$TBIS
499: /* init p0br, p0lr */
500: mtpr r0,$P0BR
501: mtpr $0,$P0LR
502: /* init p1br, p1lr */
503: movab NBPG(r0),r0
504: movl $0x200000-UPAGES,r1
505: mtpr r1,$P1LR
506: mnegl r1,r1
507: moval -4*UPAGES(r0)[r1],r2
508: mtpr r2,$P1BR
509: /* setup mapping for UPAGES of _u */
510: movl $UPAGES,r2; movab _u+NBPG*UPAGES,r1; addl2 $UPAGES,r3; jbr 2f
511: 1: decl r3
512: moval -NBPG(r1),r1;
513: bisl3 $PG_V|PG_URKW,r3,-(r0)
514: mtpr r1,$TBIS
515: 2: sobgeq r2,1b
516: /* initialize (slightly) the pcb */
517: movab UPAGES*NBPG(r1),PCB_KSP(r1)
518: mnegl $1,PCB_ESP(r1)
519: mnegl $1,PCB_SSP(r1)
520: movl r1,PCB_USP(r1)
521: mfpr $P0BR,PCB_P0BR(r1)
522: mfpr $P0LR,PCB_P0LR(r1)
523: movb $4,PCB_P0LR+3(r1) # disable ast
524: mfpr $P1BR,PCB_P1BR(r1)
525: mfpr $P1LR,PCB_P1LR(r1)
526: movl $CLSIZE,PCB_SZPT(r1) # init u.u_pcb.pcb_szpt
527: movl r11,PCB_R11(r1)
528: movab 1f,PCB_PC(r1) # initial pc
529: clrl PCB_PSL(r1) # mode(k,k), ipl=0
530: ashl $PGSHIFT,r3,r3
531: mtpr r3,$PCBB # first pcbb
532: /* set regs, p0br, p0lr, p1br, p1lr, astlvl, ksp and change to kernel mode */
533: ldpctx
534: rei
535: /* put signal trampoline code in u. area */
536: 1: movab _u,r0
537: movc3 $12,sigcode,PCB_SIGC(r0)
538: /* save reboot flags in global _boothowto */
539: movl r11,_boothowto
540: /* calculate firstaddr, and call main() */
541: movab _end+NBPG-1,r0; bbcc $31,r0,0f; 0:; ashl $-PGSHIFT,r0,-(sp)
542: addl2 $UPAGES+1,(sp); calls $1,_main
543: /* proc[1] == /etc/init now running here; run icode */
544: pushl $PSL_CURMOD|PSL_PRVMOD; pushl $0; rei
545:
546: /* signal trampoline code: it is known that this code takes exactly 12 bytes */
547: /* in ../h/pcb.h and in the movc3 above */
548: sigcode:
549: calls $3,1(pc)
550: rei
551: .word 0x7f # registers 0-6 (6==sp/compat)
552: callg (ap),*12(ap)
553: ret
554:
555: /*
556: * Primitives
557: */
558:
559: /*
560: * badaddr(addr, len)
561: * see if access addr with a len type instruction causes a machine check
562: * len is length of access (1=byte, 2=short, 4=long)
563: */
564: .globl _badaddr
565: _badaddr:
566: .word 0
567: movl $1,r0
568: mfpr $IPL,r1
569: mtpr $HIGH,$IPL
570: movl _scb+MCKVEC,r2
571: movl 4(ap),r3
572: movl 8(ap),r4
573: movab 9f+INTSTK,_scb+MCKVEC
574: bbc $0,r4,1f; tstb (r3)
575: 1: bbc $1,r4,1f; tstw (r3)
576: 1: bbc $2,r4,1f; tstl (r3)
577: 1: clrl r0 # made it w/o machine checks
578: 2: movl r2,_scb+MCKVEC
579: mtpr r1,$IPL
580: ret
581: .align 2
582: 9:
583: casel _cpu,$1,$VAX_MAX
584: 0:
585: .word 8f-0b # 1 is 780
586: .word 5f-0b # 2 is 750
587: .word 5f-0b # 3 is 7ZZ
588: 5:
589: #if defined(VAX750) || defined(VAX7ZZ)
590: mtpr $0xf,$MCESR
591: #endif
592: brb 1f
593: 8:
594: #if VAX780
595: mtpr $0,$SBIFS
596: #endif
597: 1:
598: addl2 (sp)+,sp # discard mchchk trash
599: movab 2b,(sp)
600: rei
601:
602: _addupc: .globl _addupc
603: .word 0x0
604: movl 8(ap),r2 # &u.u_prof
605: subl3 8(r2),4(ap),r0 # corrected pc
606: blss 9f
607: extzv $1,$31,r0,r0 # logical right shift
608: extzv $1,$31,12(r2),r1 # ditto for scale
609: emul r1,r0,$0,r0
610: ashq $-14,r0,r0
611: tstl r1
612: bneq 9f
613: incl r0
614: bicl2 $1,r0
615: cmpl r0,4(r2) # length
616: bgequ 9f
617: addl2 (r2),r0 # base
618: probew $3,$2,(r0)
619: beql 8f
620: addw2 12(ap),(r0)
621: 9:
622: ret
623: 8:
624: clrl 12(r2)
625: ret
626:
627: _Copyin: .globl _Copyin # <<<massaged for jsb by asm.sed>>>
628: movl 12(sp),r0 # copy length
629: blss ersb
630: movl 4(sp),r1 # copy user address
631: cmpl $NBPG,r0 # probing one page or less ?
632: bgeq cishort # yes
633: ciloop:
634: prober $3,$NBPG,(r1) # bytes accessible ?
635: beql ersb # no
636: addl2 $NBPG,r1 # incr user address ptr
637: acbl $NBPG+1,$-NBPG,r0,ciloop # reduce count and loop
638: cishort:
639: prober $3,r0,(r1) # bytes accessible ?
640: beql ersb # no
641: movc3 12(sp),*4(sp),*8(sp)
642: clrl r0
643: rsb
644:
645: ersb:
646: mnegl $1,r0
647: rsb
648:
649: _Copyout: .globl _Copyout # <<<massaged for jsb by asm.sed >>>
650: movl 12(sp),r0 # get count
651: blss ersb
652: movl 8(sp),r1 # get user address
653: cmpl $NBPG,r0 # can do in one probew?
654: bgeq coshort # yes
655: coloop:
656: probew $3,$NBPG,(r1) # bytes accessible?
657: beql ersb # no
658: addl2 $NBPG,r1 # increment user address
659: acbl $NBPG+1,$-NBPG,r0,coloop # reduce count and loop
660: coshort:
661: probew $3,r0,(r1) # bytes accessible?
662: beql ersb # no
663: movc3 12(sp),*4(sp),*8(sp)
664: clrl r0
665: rsb
666:
667: /*
668: * non-local goto's
669: */
670: .globl _Setjmp
671: _Setjmp:
672: movq r6,(r0)+
673: movq r8,(r0)+
674: movq r10,(r0)+
675: movq r12,(r0)+
676: addl3 $4,sp,(r0)+
677: movl (sp),(r0)
678: clrl r0
679: rsb
680:
681: .globl _Longjmp
682: _Longjmp:
683: movq (r0)+,r6
684: movq (r0)+,r8
685: movq (r0)+,r10
686: movq (r0)+,r12
687: movl (r0)+,r1
688: cmpl r1,sp # must be a pop
689: bgequ lj2
690: pushab lj1
691: calls $1,_panic
692: lj2:
693: movl r1,sp
694: jmp *(r0) # ``rsb''
695:
696: lj1: .asciz "longjmp"
697:
698: .globl _whichqs
699: .globl _qs
700: .globl _cnt
701:
702: .globl _noproc
703: .comm _noproc,4
704: .globl _runrun
705: .comm _runrun,4
706:
707: /*
708: * The following primitives use the fancy VAX instructions
709: * much like VMS does. _whichqs tells which of the 32 queues _qs
710: * have processes in them. Setrq puts processes into queues, Remrq
711: * removes them from queues. The running process is on no queue,
712: * other processes are on a queue related to p->p_pri, divided by 4
713: * actually to shrink the 0-127 range of priorities into the 32 available
714: * queues.
715: */
716:
717: /*
718: * Setrq(p), using fancy VAX instructions.
719: *
720: * Call should be made at spl6(), and p->p_stat should be SRUN
721: */
722: .globl _Setrq # <<<massaged to jsb by "asm.sed">>>
723: _Setrq:
724: tstl P_RLINK(r0) ## firewall: p->p_rlink must be 0
725: beql set1 ##
726: pushab set3 ##
727: calls $1,_panic ##
728: set1:
729: movzbl P_PRI(r0),r1 # put on queue which is p->p_pri / 4
730: ashl $-2,r1,r1
731: movaq _qs[r1],r2
732: insque (r0),*4(r2) # at end of queue
733: bbss r1,_whichqs,set2 # mark queue non-empty
734: set2:
735: rsb
736:
737: set3: .asciz "setrq"
738:
739: /*
740: * Remrq(p), using fancy VAX instructions
741: *
742: * Call should be made at spl6().
743: */
744: .globl _Remrq # <<<massaged to jsb by "asm.sed">>>
745: _Remrq:
746: movzbl P_PRI(r0),r1
747: ashl $-2,r1,r1
748: bbsc r1,_whichqs,rem1
749: pushab rem3 # it wasn't recorded to be on its q
750: calls $1,_panic
751: rem1:
752: remque (r0),r2
753: beql rem2
754: bbss r1,_whichqs,rem2
755: rem2:
756: clrl P_RLINK(r0) ## for firewall checking
757: rsb
758:
759: rem3: .asciz "remrq"
760:
761: /*
762: * Masterpaddr is the p->p_addr of the running process on the master
763: * processor. When a multiprocessor system, the slave processors will have
764: * an array of slavepaddr's.
765: */
766: .globl _masterpaddr
767: .data
768: _masterpaddr:
769: .long 0
770:
771: .text
772: sw0: .asciz "swtch"
773: /*
774: * Swtch(), using fancy VAX instructions
775: */
776: .globl _Swtch
777: _Swtch: # <<<massaged to jsb by "asm.sed">>>
778: movl $1,_noproc
779: clrl _runrun
780: sw1: ffs $0,$32,_whichqs,r0 # look for non-empty queue
781: bneq sw1a
782: mtpr $0,$IPL # must allow interrupts here
783: brw sw1 # this is an idle loop!
784: sw1a: mtpr $0x18,$IPL # lock out all so _whichqs==_qs
785: bbcc r0,_whichqs,sw1 # proc moved via lbolt interrupt
786: movaq _qs[r0],r1
787: remque *(r1),r2 # r2 = p = highest pri process
788: bvc sw2 # make sure something was there
789: sw1b: pushab sw0
790: calls $1,_panic
791: sw2: beql sw3
792: insv $1,r0,$1,_whichqs # still more procs in this queue
793: sw3:
794: clrl _noproc
795: tstl P_WCHAN(r2) ## firewalls
796: bneq sw1b ##
797: movzbl P_STAT(r2),r3 ##
798: cmpl $SRUN,r3 ##
799: bneq sw1b ##
800: clrl P_RLINK(r2) ##
801: movl *P_ADDR(r2),r0
802: movl r0,_masterpaddr
803: ashl $PGSHIFT,r0,r0 # r0 = pcbb(p)
804: /* mfpr $PCBB,r1 # resume of current proc is easy
805: * cmpl r0,r1
806: */ beql res0
807: incl _cnt+V_SWTCH
808: /* fall into... */
809:
810: /*
811: * Resume(pf)
812: */
813: .globl _Resume # <<<massaged to jsb by "asm.sed">>>
814: _Resume:
815: mtpr $0x18,$IPL # no interrupts, please
816: movl _CMAP2,_u+PCB_CMAP2 # yech
817: svpctx
818: mtpr r0,$PCBB
819: ldpctx
820: movl _u+PCB_CMAP2,_CMAP2 # yech
821: mtpr $_CADDR2,$TBIS
822: res0:
823: tstl _u+PCB_SSWAP
824: beql res1
825: movl _u+PCB_SSWAP,r0
826: clrl _u+PCB_SSWAP
827: movab _Longjmp,(sp)
828: movl $PSL_PRVMOD,4(sp) # ``cheating'' (jfr)
829: res1:
830: rei
831:
832: /*
833: * {fu,su},{byte,word}, all massaged by asm.sed to jsb's
834: */
835: .globl _Fuword
836: _Fuword:
837: prober $3,$4,(r0)
838: beql fserr
839: movl (r0),r0
840: rsb
841: fserr:
842: mnegl $1,r0
843: rsb
844:
845: .globl _Fubyte
846: _Fubyte:
847: prober $3,$1,(r0)
848: beql fserr
849: movzbl (r0),r0
850: rsb
851:
852: .globl _Suword
853: _Suword:
854: probew $3,$4,(r0)
855: beql fserr
856: movl r1,(r0)
857: clrl r0
858: rsb
859:
860: .globl _Subyte
861: _Subyte:
862: probew $3,$1,(r0)
863: beql fserr
864: movb r1,(r0)
865: clrl r0
866: rsb
867:
868: /*
869: * Copy 1 relocation unit (NBPG bytes)
870: * from user virtual address to physical address
871: */
872: _copyseg: .globl _copyseg
873: .word 0x0
874: bisl3 $PG_V|PG_KW,8(ap),_CMAP2
875: mtpr $_CADDR2,$TBIS # invalidate entry for copy
876: movc3 $NBPG,*4(ap),_CADDR2
877: ret
878:
879: /*
880: * zero out physical memory
881: * specified in relocation units (NBPG bytes)
882: */
883: _clearseg: .globl _clearseg
884: .word 0x0
885: bisl3 $PG_V|PG_KW,4(ap),_CMAP1
886: mtpr $_CADDR1,$TBIS
887: movc5 $0,(sp),$0,$NBPG,_CADDR1
888: ret
889:
890: /*
891: * Check address.
892: * Given virtual address, byte count, and rw flag
893: * returns 0 on no access.
894: */
895: _useracc: .globl _useracc
896: .word 0x0
897: movl 4(ap),r0 # get va
898: movl 8(ap),r1 # count
899: tstl 12(ap) # test for read access ?
900: bneq userar # yes
901: cmpl $NBPG,r1 # can we do it in one probe ?
902: bgeq uaw2 # yes
903: uaw1:
904: probew $3,$NBPG,(r0)
905: beql uaerr # no access
906: addl2 $NBPG,r0
907: acbl $NBPG+1,$-NBPG,r1,uaw1
908: uaw2:
909: probew $3,r1,(r0)
910: beql uaerr
911: movl $1,r0
912: ret
913:
914: userar:
915: cmpl $NBPG,r1
916: bgeq uar2
917: uar1:
918: prober $3,$NBPG,(r0)
919: beql uaerr
920: addl2 $NBPG,r0
921: acbl $NBPG+1,$-NBPG,r1,uar1
922: uar2:
923: prober $3,r1,(r0)
924: beql uaerr
925: movl $1,r0
926: ret
927: uaerr:
928: clrl r0
929: ret
930:
931: /*
932: * kernacc - check for kernel access privileges
933: *
934: * We can't use the probe instruction directly because
935: * it ors together current and previous mode.
936: */
937: .globl _kernacc
938: _kernacc:
939: .word 0x0
940: movl 4(ap),r0 # virtual address
941: bbcc $31,r0,kacc1
942: bbs $30,r0,kacerr
943: mfpr $SBR,r2 # address and length of page table (system)
944: bbss $31,r2,0f; 0:
945: mfpr $SLR,r3
946: brb kacc2
947: kacc1:
948: bbsc $30,r0,kacc3
949: mfpr $P0BR,r2 # user P0
950: mfpr $P0LR,r3
951: brb kacc2
952: kacc3:
953: mfpr $P1BR,r2 # user P1 (stack)
954: mfpr $P1LR,r3
955: kacc2:
956: addl3 8(ap),r0,r1 # ending virtual address
957: addl2 $NBPG-1,r1
958: ashl $-PGSHIFT,r0,r0
959: ashl $-PGSHIFT,r1,r1
960: bbs $31,4(ap),kacc6
961: bbc $30,4(ap),kacc6
962: cmpl r0,r3 # user stack
963: blss kacerr # address too low
964: brb kacc4
965: kacc6:
966: cmpl r1,r3 # compare last page to P0LR or SLR
967: bgtr kacerr # address too high
968: kacc4:
969: movl (r2)[r0],r3
970: bbc $31,4(ap),kacc4a
971: bbc $31,r3,kacerr # valid bit is off
972: kacc4a:
973: cmpzv $27,$4,r3,$1 # check protection code
974: bleq kacerr # no access allowed
975: tstb 12(ap)
976: bneq kacc5 # only check read access
977: cmpzv $27,$2,r3,$3 # check low 2 bits of prot code
978: beql kacerr # no write access
979: kacc5:
980: aoblss r1,r0,kacc4 # next page
981: movl $1,r0 # no errors
982: ret
983: kacerr:
984: clrl r0 # error
985: ret
986: .globl _Xrkintr0
987: .align 2
988: _Xrkintr0:
989: pushr $0x3f
990: pushl $0
991: calls $1,_rkintr
992: popr $0x3f
993: rei
994:
995: .globl _Xlpintr0
996: .align 2
997: _Xlpintr0:
998: pushr $0x3f
999: pushl $0
1000: calls $1,_lpintr
1001: popr $0x3f
1002: rei
1003:
1004: .globl _Xtmintr0
1005: .align 2
1006: _Xtmintr0:
1007: pushr $0x3f
1008: pushl $0
1009: calls $1,_tmintr
1010: popr $0x3f
1011: rei
1012:
1013: .globl _Xupintr0
1014: .align 2
1015: _Xupintr0:
1016: pushr $0x3f
1017: pushl $0
1018: calls $1,_upintr
1019: popr $0x3f
1020: rei
1021:
1022: .globl _Xudintr0
1023: .align 2
1024: _Xudintr0:
1025: pushr $0x3f
1026: pushl $0
1027: calls $1,_udintr
1028: popr $0x3f
1029: rei
1030:
1031: .globl _Xdnintr0
1032: .align 2
1033: _Xdnintr0:
1034: pushr $0x3f
1035: pushl $0
1036: calls $1,_dnintr
1037: popr $0x3f
1038: rei
1039:
1040: .globl _Xdhrint0
1041: .align 2
1042: _Xdhrint0:
1043: pushr $0x3f
1044: pushl $0
1045: calls $1,_dhrint
1046: popr $0x3f
1047: rei
1048:
1049: .globl _Xdhxint0
1050: .align 2
1051: _Xdhxint0:
1052: pushr $0x3f
1053: pushl $0
1054: calls $1,_dhxint
1055: popr $0x3f
1056: rei
1057:
1058: .globl _Xdhrint1
1059: .align 2
1060: _Xdhrint1:
1061: pushr $0x3f
1062: pushl $1
1063: calls $1,_dhrint
1064: popr $0x3f
1065: rei
1066:
1067: .globl _Xdhxint1
1068: .align 2
1069: _Xdhxint1:
1070: pushr $0x3f
1071: pushl $1
1072: calls $1,_dhxint
1073: popr $0x3f
1074: rei
1075:
1076: .globl _Xdzrint0
1077: .align 2
1078: _Xdzrint0:
1079: pushr $0x3f
1080: pushl $0
1081: calls $1,_dzrint
1082: popr $0x3f
1083: rei
1084:
1085: .globl _Xdzxint0
1086: .align 2
1087: _Xdzxint0:
1088: pushr $0x3f
1089: movl $0,r0
1090: jbr _dzdma
1091:
1092: .globl _Xdzrint1
1093: .align 2
1094: _Xdzrint1:
1095: pushr $0x3f
1096: pushl $1
1097: calls $1,_dzrint
1098: popr $0x3f
1099: rei
1100:
1101: .globl _Xdzxint1
1102: .align 2
1103: _Xdzxint1:
1104: pushr $0x3f
1105: movl $1,r0
1106: jbr _dzdma
1107:
1108: .globl _Xdzrint2
1109: .align 2
1110: _Xdzrint2:
1111: pushr $0x3f
1112: pushl $2
1113: calls $1,_dzrint
1114: popr $0x3f
1115: rei
1116:
1117: .globl _Xdzxint2
1118: .align 2
1119: _Xdzxint2:
1120: pushr $0x3f
1121: movl $2,r0
1122: jbr _dzdma
1123:
1124: .globl _Xdzrint3
1125: .align 2
1126: _Xdzrint3:
1127: pushr $0x3f
1128: pushl $3
1129: calls $1,_dzrint
1130: popr $0x3f
1131: rei
1132:
1133: .globl _Xdzxint3
1134: .align 2
1135: _Xdzxint3:
1136: pushr $0x3f
1137: movl $3,r0
1138: jbr _dzdma
1139:
1140: .globl _Xdzrint4
1141: .align 2
1142: _Xdzrint4:
1143: pushr $0x3f
1144: pushl $4
1145: calls $1,_dzrint
1146: popr $0x3f
1147: rei
1148:
1149: .globl _Xdzxint4
1150: .align 2
1151: _Xdzxint4:
1152: pushr $0x3f
1153: movl $4,r0
1154: jbr _dzdma
1155:
1156: .globl _Xdzrint5
1157: .align 2
1158: _Xdzrint5:
1159: pushr $0x3f
1160: pushl $5
1161: calls $1,_dzrint
1162: popr $0x3f
1163: rei
1164:
1165: .globl _Xdzxint5
1166: .align 2
1167: _Xdzxint5:
1168: pushr $0x3f
1169: movl $5,r0
1170: jbr _dzdma
1171:
1172: .globl _Xdzrint6
1173: .align 2
1174: _Xdzrint6:
1175: pushr $0x3f
1176: pushl $6
1177: calls $1,_dzrint
1178: popr $0x3f
1179: rei
1180:
1181: .globl _Xdzxint6
1182: .align 2
1183: _Xdzxint6:
1184: pushr $0x3f
1185: movl $6,r0
1186: jbr _dzdma
1187:
1188: .globl _Xdzrint7
1189: .align 2
1190: _Xdzrint7:
1191: pushr $0x3f
1192: pushl $7
1193: calls $1,_dzrint
1194: popr $0x3f
1195: rei
1196:
1197: .globl _Xdzxint7
1198: .align 2
1199: _Xdzxint7:
1200: pushr $0x3f
1201: movl $7,r0
1202: jbr _dzdma
1203:
1204: .globl _Xtsintr0
1205: .align 2
1206: _Xtsintr0:
1207: pushr $0x3f
1208: pushl $0
1209: calls $1,_tsintr
1210: popr $0x3f
1211: rei
1212:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.