diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2010-05-29 14:08:23 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2010-05-29 14:08:23 +0000 |
commit | e15f69614dad01ba7030831a1fb62013d42d1c92 (patch) | |
tree | 53c32233783bd79c712993caee4a05f927848239 | |
parent | 717870d57a4ff08c2f5f19e5e2120694e6d4f73c (diff) |
merge subr.s into locore.S, which requires a fairly complicated dance
mixing and matching the various styles of *ENTRY* macros
prescribed by miod, ok ragge, tested by jasper
-rw-r--r-- | sys/arch/vax/conf/Makefile.vax | 8 | ||||
-rw-r--r-- | sys/arch/vax/include/asm.h | 10 | ||||
-rw-r--r-- | sys/arch/vax/vax/locore.S | 369 | ||||
-rw-r--r-- | sys/arch/vax/vax/subr.s | 381 |
4 files changed, 365 insertions, 403 deletions
diff --git a/sys/arch/vax/conf/Makefile.vax b/sys/arch/vax/conf/Makefile.vax index b4596775348..7cacbc2694b 100644 --- a/sys/arch/vax/conf/Makefile.vax +++ b/sys/arch/vax/conf/Makefile.vax @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.vax,v 1.56 2010/05/28 14:27:08 guenther Exp $ +# $OpenBSD: Makefile.vax,v 1.57 2010/05/29 14:08:20 deraadt Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -68,7 +68,7 @@ NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< # ${SYSTEM_LD_HEAD} # ${SYSTEM_LD} swapxxx.o # ${SYSTEM_LD_TAIL} -SYSTEM_OBJ= locore.o subr.o param.o ioconf.o ${OBJS} +SYSTEM_OBJ= locore.o param.o ioconf.o ${OBJS} SYSTEM_DEP= Makefile ${SYSTEM_OBJ} SYSTEM_LD_HEAD= @rm -f $@ SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \ @@ -124,7 +124,7 @@ lint: tags: @echo "see $S/kern/Makefile for tags" -AFILES= ${_machdir}/${_mach}/locore.S ${_machdir}/${_mach}/subr.s +AFILES= ${_machdir}/${_mach}/locore.S depend:: .depend .depend: ${AFILES} param.c ioconf.c ${CFILES} ${SFILES} assym.h ${DB_STRUCTINFO} ${MKDEP} ${AFLAGS} ${CPPFLAGS} ${AFILES} @@ -144,7 +144,7 @@ db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.awk rm -f db_structinfo.o locore.o: ${_machdir}/${_mach}/locore.S assym.h -subr.o unimpl_emul.o: assym.h +unimpl_emul.o: assym.h # The install target can be redefined by putting a # install-kernel-${MACHINE_NAME} target into /etc/mk.conf diff --git a/sys/arch/vax/include/asm.h b/sys/arch/vax/include/asm.h index aef8f8f2f23..13193b10333 100644 --- a/sys/arch/vax/include/asm.h +++ b/sys/arch/vax/include/asm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asm.h,v 1.9 2008/05/21 20:33:39 miod Exp $ */ +/* $OpenBSD: asm.h,v 1.10 2010/05/29 14:08:21 deraadt Exp $ */ /* $NetBSD: asm.h,v 1.9 1999/01/15 13:31:28 bouyer Exp $ */ /* * Copyright (c) 1982, 1993 @@ -93,9 +93,11 @@ # define _PROF_PROLOGUE #endif -#define ENTRY(x, regs) _ENTRY(_C_LABEL(x), regs); _PROF_PROLOGUE -#define NENTRY(x, regs) _ENTRY(_C_LABEL(x), regs) -#define ASENTRY(x, regs) _ENTRY(_ASM_LABEL(x), regs); _PROF_PROLOGUE +#define ENTRY(x, regs) _ENTRY(_C_LABEL(x), regs); _PROF_PROLOGUE +#define ENTRY_NOPROFILE(x, regs) _ENTRY(_C_LABEL(x), regs) +#define NENTRY(x, regs) _ENTRY(_C_LABEL(x), regs) +#define ASENTRY(x, regs) _ENTRY(_ASM_LABEL(x), regs); _PROF_PROLOGUE +#define ASENTRY_NOPROFILE(x, regs) _ENTRY(_ASM_LABEL(x), regs) #define ALTENTRY(x) _ALTENTRY(_C_LABEL(x)) #define RCSID(x) .text; .asciz x diff --git a/sys/arch/vax/vax/locore.S b/sys/arch/vax/vax/locore.S index 5c61f513dfa..0dfd5daa96a 100644 --- a/sys/arch/vax/vax/locore.S +++ b/sys/arch/vax/vax/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.1 2010/05/26 16:35:28 deraadt Exp $ */ +/* $OpenBSD: locore.S,v 1.2 2010/05/29 14:08:22 deraadt Exp $ */ /* $NetBSD: intvec.s,v 1.39 1999/06/28 08:20:48 itojun Exp $ */ /* @@ -34,27 +34,29 @@ #include "assym.h" +#include <machine/asm.h> #include <net/netisr.h> -#define ENTRY(name) \ - .text ; \ - .align 2 ; \ - .globl name ; \ -name /**/: +#define JSBENTRY(x) \ + .text; _ALIGN_TEXT; .globl x; x: + +#ifdef COMPAT_ULTRIX +#include <compat/ultrix/ultrix_syscall.h> +#endif #define TRAPCALL(namn, typ) \ -ENTRY(namn) ; \ +JSBENTRY(namn) ; \ pushl $0 ; \ pushl $typ ; \ jbr trap #define TRAPARGC(namn, typ) \ -ENTRY(namn) ; \ +JSBENTRY(namn) ; \ pushl $typ ; \ jbr trap #define FASTINTR(namn, rutin) \ -ENTRY(namn) ; \ +JSBENTRY(namn) ; \ pushr $0x3f ; \ calls $0,_/**/rutin ; \ popr $0x3f ; \ @@ -194,7 +196,7 @@ L4: addl2 (sp)+,sp # remove info pushed on stack TRAPCALL(invkstk, T_KSPNOTVAL) -ENTRY(privinflt) # Privileged/unimplemented instruction +JSBENTRY(privinflt) # Privileged/unimplemented instruction #ifdef INSN_EMULATE jsb unimemu # do not return if insn emulated #endif @@ -249,7 +251,7 @@ TRAPCALL(breakp, T_BPTFLT) TRAPARGC(arithflt, T_ARITHFLT) -ENTRY(syscall) # Main system call +JSBENTRY(syscall) # Main system call pushl $T_SYSCALL pushr $0xfff mfpr $PR_USP, -(sp) @@ -266,14 +268,14 @@ ENTRY(syscall) # Main system call rei -ENTRY(cmrerr) +JSBENTRY(cmrerr) PUSHR movl _dep_call,r0 calls $0,*MEMERR(r0) POPR rei -ENTRY(sbiflt) +JSBENTRY(sbiflt) pushab sbifltmsg calls $1, _panic @@ -288,7 +290,7 @@ _netisr: TRAPCALL(ddbtrap, T_KDBTRAP) -ENTRY(hardclock) +JSBENTRY(hardclock) mtpr $0xc1,$PR_ICCS # Reset interrupt flag PUSHR pushl sp @@ -413,3 +415,342 @@ noemulate: _scb: .long 0 .globl _scb + .text + +/* + * First entry routine from boot. This should be in a file called locore. + */ +ASENTRY_NOPROFILE(start, 0) + bisl3 $0x80000000,r9,_esym # End of loaded code + pushl $0x1f0000 # Push a nice PSL + pushl $to # Address to jump to + rei # change to kernel stack +to: movw $0xfff,_panic # Save all regs in panic + moval _end, r0 # Get kernel end address + addl2 $0x3ff, r0 # Round it up + cmpl _esym, r0 # Compare with symbol table end + bleq eskip # Symbol table not present + addl3 _esym, $0x3ff, r0 # Use symbol end and round +eskip: + bicl3 $0x3ff,r0,_proc0paddr # save proc0 uarea pointer + bicl3 $0x80000000,_proc0paddr,r0 # get phys proc0 uarea addr + mtpr r0,$PR_PCBB # Save in IPR PCBB + addl3 $USPACE,_proc0paddr,r0 # Get kernel stack top + mtpr r0,$PR_KSP # put in IPR KSP + movl r0,_Sysmap # SPT start addr after KSP + +# Set some registers in known state + movl _proc0paddr,r0 + clrl P0LR(r0) + clrl P1LR(r0) + mtpr $0,$PR_P0LR + mtpr $0,$PR_P1LR + movl $0x80000000,r1 + movl r1,P0BR(r0) + movl r1,P1BR(r0) + mtpr r1,$PR_P0BR + mtpr r1,$PR_P1BR + clrl IFTRAP(r0) + mtpr $0,$PR_SCBB + +# Copy the RPB to its new position +#if 1 /* compat with old bootblocks */ + tstl (ap) # Any arguments? + bneq 1f # Yes, called from new boot + movl r11,_boothowto # Howto boot (single etc...) +# movl r10,_bootdev # uninteresting, will complain + movl r8,_avail_end # Usable memory (from VMB) + clrl -(sp) # Have no RPB + brb 2f +#endif + +1: pushl 4(ap) # Address of old rpb +2: calls $1,_start # Jump away. + /* NOTREACHED */ + + +/* + * Signal handler code. + */ + + .globl _sigcode,_esigcode +_sigcode: + movl 0x0c(sp),r0 /* get signal handler */ + calls $3,(r0) /* and call it */ + chmk $SYS_sigreturn /* sigreturn frame set up by sendsig */ + chmk $SYS_exit + halt + .align 2 +_esigcode: + +#ifdef COMPAT_ULTRIX + .globl _ultrix_sigcode,_ultrix_esigcode +_ultrix_sigcode: pushr $0x3f + subl2 $0xc,sp + movl 0x24(sp),r0 + calls $3,(r0) + popr $0x3f + chmk $ULTRIX_SYS_sigreturn + chmk $SYS_exit + halt + .align 2 +_ultrix_esigcode: +#endif + + .globl _idsptch, _eidsptch +_idsptch: pushr $0x3f + .word 0x9f16 # jsb to absolute address + .long _cmn_idsptch # the absolute address + .long 0 # the callback interrupt routine + .long 0 # its argument + .long 0 # ptr to correspond evcount struct +_eidsptch: + +_cmn_idsptch: + movl (sp)+,r0 # get pointer to idspvec + movl 8(r0),r1 # get evcount pointer + beql 1f # no ptr, skip increment + incl EC_COUNT(r1) # increment low longword + adwc $0,EC_COUNT+4(r1) # add any carry to hi longword +1: pushl 4(r0) # push argument + calls $1,*(r0) # call interrupt routine + popr $0x3f # pop registers + rei # return from interrut + +ENTRY_NOPROFILE(badaddr,R2|R3) # Called with addr,b/w/l + mfpr $0x12,r0 # splhigh() + mtpr $0x1f,$0x12 + movl 4(ap),r2 # First argument, the address + movl 8(ap),r1 # Sec arg, b,w,l + pushl r0 # Save old IPL + clrl r3 + movab 4f,_memtest # Set the return address + + caseb r1,$1,$4 # What is the size +1: .word 1f-1b + .word 2f-1b + .word 3f-1b # This is unused + .word 3f-1b + +1: movb (r2),r1 # Test a byte + brb 5f + +2: movw (r2),r1 # Test a word + brb 5f + +3: movl (r2),r1 # Test a long + brb 5f + +4: incl r3 # Got machine chk => addr bad +5: mtpr (sp)+,$0x12 + movl r3,r0 + ret + +#ifdef DDB +/* + * DDB is the only routine that uses setjmp/longjmp. + */ +ENTRY_NOPROFILE(setjmp, 0) + movl 4(ap), r0 + movl 8(fp), (r0) + movl 12(fp), 4(r0) + movl 16(fp), 8(r0) + addl3 fp,$28,12(r0) + clrl r0 + ret + +ENTRY_NOPROFILE(longjmp, 0) + movl 4(ap), r1 + movl $1, r0 + movl (r1), ap + movl 4(r1), fp + movl 12(r1), sp + jmp *8(r1) +#endif + +# +# void +# cpu_switchto(struct proc *oldproc = r0, struct proc *newproc = r1); +# + +#define CURPROC _cpu_info_store + CI_CURPROC + +JSBENTRY(__cpu_switchto) + svpctx + + movb $SONPROC,P_STAT(r1) # p->p_stat = SONPROC + movl r1, CURPROC # set new process running + + movl P_ADDR(r1),r0 # Get pointer to new pcb. + addl3 r0,$IFTRAP,pcbtrap # Save for copy* functions. + + # inline kvtophys + extzv $9,$21,r0,r1 # extract offset + movl *_Sysmap[r1],r2 # get pte + ashl $9,r2,r3 # shift to get phys address. + +# +# Do the actual process switch. pc + psl are already on stack, from +# the beginning of this routine. +# + mtpr r3,$PR_PCBB + + pushl CURPROC + calls $1, _C_LABEL(pmap_activate) + + ldpctx + rei + +# +# copy/fetch/store routines. +# + .align 2,1 +ENTRY_NOPROFILE(copyin, R2|R3|R4|R5|R6) + movl 4(ap), r0 + blss 3f # kernel space + movl 8(ap), r1 + brb 2f + +ENTRY_NOPROFILE(copyout, R2|R3|R4|R5|R6) + movl 8(ap), r1 + blss 3f # kernel space + movl 4(ap), r0 +2: movab 1f,*pcbtrap + movzwl 12(ap), r2 + movzwl 14(ap), r6 + + movc3 r2, (r0), (r1) + + tstl r6 + bleq 1f +0: movb (r1)+, (r3)+ + movc3 $0xffff, (r1), (r3) + sobgtr r6,0b + +1: clrl *pcbtrap + ret + +3: movl $EFAULT, r0 + ret + +/* kcopy: just like bcopy, except return -1 upon failure */ +ENTRY_NOPROFILE(kcopy,R2|R3|R4|R5|R6) + movl *pcbtrap,-(sp) + movab 2f,*pcbtrap + movl 4(ap), r0 + movl 8(ap), r1 + movzwl 12(ap), r2 + movzwl 14(ap), r6 + + movc3 r2, (r0), (r1) + + tstl r6 + bleq 1f +0: movb (r1)+, (r3)+ + movc3 $0xffff, (r1), (r3) + sobgtr r6, 0b + + /* + * If there is a failure, trap.c will set r1 to -1, and jump + * to the following 2. If not, we return 0. We duplicate a + * minuscule amount of code in the interest of speed; movc3 + * sets r0 to 0 anyway. + */ +1: + movl (sp)+,*pcbtrap + ret + +2: movl (sp)+,*pcbtrap + movl r1,r0 + ret + +ENTRY_NOPROFILE(copyinstr,0) + tstl 4(ap) # is from a kernel address? + bgeq 8f # no, continue + +6: movl $EFAULT,r0 + ret + +ENTRY_NOPROFILE(copyoutstr,0) + tstl 8(ap) # is to a kernel address? + bgeq 8f # no, continue + brb 6b + +ENTRY_NOPROFILE(copystr,0) +8: movl 4(ap),r4 # from + movl 8(ap),r5 # to + movl 16(ap),r3 # copied + movl 12(ap),r2 # len + + bneq 1f # nothing to copy? + movl $ENAMETOOLONG,r0 + tstl r3 + beql 0f + movl $0,(r3) +0: ret + +1: movab 2f,*pcbtrap + +/* + * This routine consists of two parts: One is for MV2 that doesn't have + * locc in hardware, the other is a fast version with locc. But because + * locc only handles <64k strings, we default to the slow version if the + * string is longer. + */ + cmpl _vax_cputype,$VAX_TYP_UV2 + bneq 4f # Check if locc emulated + +9: movl r2,r0 +7: movb (r4)+,(r5)+ + beql 6f # end of string + sobgtr r0,7b # no null byte in the len first bytes? + brb 1f + +6: tstl r3 + beql 5f + incl r2 + subl3 r0,r2,(r3) +5: clrl r0 + clrl *pcbtrap + ret + +4: cmpl r2,$65535 # maxlen < 64k? + blss 8f # then use fast code. + + locc $0,$65535,(r4) # is strlen < 64k? + beql 9b # No, use slow code + subl3 r0,$65535,r1 # Get string len + brb 0f # do the copy + +8: locc $0,r2,(r4) # check for null byte + beql 1f + + subl3 r0,r2,r1 # Calculate len to copy +0: incl r1 # Copy null byte also + tstl r3 + beql 3f + movl r1,(r3) # save len copied +3: movc3 r1,(r4),(r5) + brb 4f + +1: movl $ENAMETOOLONG,r0 +2: movab 4f,*pcbtrap # if we fault again, don't resume there + subl3 8(ap),r5,r1 # did we write to the string? + beql 3f + decl r5 +3: movb $0,(r5) # null terminate the output string + tstl r3 + beql 4f + incl r1 # null byte accounts for outlen... + movl r1,(r3) # save len copied +4: clrl *pcbtrap + ret + +# +# data department +# + .data + +_memtest: .long 0 ; .globl _memtest # Memory test in progress. +pcbtrap: .long 0x800001fc; .globl pcbtrap # Safe place +_bootdev: .long 0; .globl _bootdev diff --git a/sys/arch/vax/vax/subr.s b/sys/arch/vax/vax/subr.s deleted file mode 100644 index c4db61b0e83..00000000000 --- a/sys/arch/vax/vax/subr.s +++ /dev/null @@ -1,381 +0,0 @@ -/* $OpenBSD: subr.s,v 1.30 2009/08/19 19:47:53 miod Exp $ */ -/* $NetBSD: subr.s,v 1.32 1999/03/25 00:41:48 mrg Exp $ */ - -/* - * Copyright (c) 1994 Ludd, University of Lule}, Sweden. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed at Ludd, University of Lule}. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <machine/asm.h> - -#include "assym.h" -#ifdef COMPAT_ULTRIX -#include <compat/ultrix/ultrix_syscall.h> -#endif - -#define JSBENTRY(x) .globl x ; .align 2 ; x : - - .text - -/* - * First entry routine from boot. This should be in a file called locore. - */ -ASENTRY(start, 0) - bisl3 $0x80000000,r9,_esym # End of loaded code - pushl $0x1f0000 # Push a nice PSL - pushl $to # Address to jump to - rei # change to kernel stack -to: movw $0xfff,_panic # Save all regs in panic - moval _end, r0 # Get kernel end address - addl2 $0x3ff, r0 # Round it up - cmpl _esym, r0 # Compare with symbol table end - bleq eskip # Symbol table not present - addl3 _esym, $0x3ff, r0 # Use symbol end and round -eskip: - bicl3 $0x3ff,r0,_proc0paddr # save proc0 uarea pointer - bicl3 $0x80000000,_proc0paddr,r0 # get phys proc0 uarea addr - mtpr r0,$PR_PCBB # Save in IPR PCBB - addl3 $USPACE,_proc0paddr,r0 # Get kernel stack top - mtpr r0,$PR_KSP # put in IPR KSP - movl r0,_Sysmap # SPT start addr after KSP - -# Set some registers in known state - movl _proc0paddr,r0 - clrl P0LR(r0) - clrl P1LR(r0) - mtpr $0,$PR_P0LR - mtpr $0,$PR_P1LR - movl $0x80000000,r1 - movl r1,P0BR(r0) - movl r1,P1BR(r0) - mtpr r1,$PR_P0BR - mtpr r1,$PR_P1BR - clrl IFTRAP(r0) - mtpr $0,$PR_SCBB - -# Copy the RPB to its new position -#if 1 /* compat with old bootblocks */ - tstl (ap) # Any arguments? - bneq 1f # Yes, called from new boot - movl r11,_boothowto # Howto boot (single etc...) -# movl r10,_bootdev # uninteresting, will complain - movl r8,_avail_end # Usable memory (from VMB) - clrl -(sp) # Have no RPB - brb 2f -#endif - -1: pushl 4(ap) # Address of old rpb -2: calls $1,_start # Jump away. - /* NOTREACHED */ - - -/* - * Signal handler code. - */ - - .globl _sigcode,_esigcode -_sigcode: - movl 0x0c(sp),r0 /* get signal handler */ - calls $3,(r0) /* and call it */ - chmk $SYS_sigreturn /* sigreturn frame set up by sendsig */ - chmk $SYS_exit - halt - .align 2 -_esigcode: - -#ifdef COMPAT_ULTRIX - .globl _ultrix_sigcode,_ultrix_esigcode -_ultrix_sigcode: pushr $0x3f - subl2 $0xc,sp - movl 0x24(sp),r0 - calls $3,(r0) - popr $0x3f - chmk $ULTRIX_SYS_sigreturn - chmk $SYS_exit - halt - .align 2 -_ultrix_esigcode: -#endif - - .globl _idsptch, _eidsptch -_idsptch: pushr $0x3f - .word 0x9f16 # jsb to absolute address - .long _cmn_idsptch # the absolute address - .long 0 # the callback interrupt routine - .long 0 # its argument - .long 0 # ptr to correspond evcount struct -_eidsptch: - -_cmn_idsptch: - movl (sp)+,r0 # get pointer to idspvec - movl 8(r0),r1 # get evcount pointer - beql 1f # no ptr, skip increment - incl EC_COUNT(r1) # increment low longword - adwc $0,EC_COUNT+4(r1) # add any carry to hi longword -1: pushl 4(r0) # push argument - calls $1,*(r0) # call interrupt routine - popr $0x3f # pop registers - rei # return from interrut - -ENTRY(badaddr,R2|R3) # Called with addr,b/w/l - mfpr $0x12,r0 # splhigh() - mtpr $0x1f,$0x12 - movl 4(ap),r2 # First argument, the address - movl 8(ap),r1 # Sec arg, b,w,l - pushl r0 # Save old IPL - clrl r3 - movab 4f,_memtest # Set the return address - - caseb r1,$1,$4 # What is the size -1: .word 1f-1b - .word 2f-1b - .word 3f-1b # This is unused - .word 3f-1b - -1: movb (r2),r1 # Test a byte - brb 5f - -2: movw (r2),r1 # Test a word - brb 5f - -3: movl (r2),r1 # Test a long - brb 5f - -4: incl r3 # Got machine chk => addr bad -5: mtpr (sp)+,$0x12 - movl r3,r0 - ret - -#ifdef DDB -/* - * DDB is the only routine that uses setjmp/longjmp. - */ -ENTRY(setjmp, 0) - movl 4(ap), r0 - movl 8(fp), (r0) - movl 12(fp), 4(r0) - movl 16(fp), 8(r0) - addl3 fp,$28,12(r0) - clrl r0 - ret - -ENTRY(longjmp, 0) - movl 4(ap), r1 - movl $1, r0 - movl (r1), ap - movl 4(r1), fp - movl 12(r1), sp - jmp *8(r1) -#endif - -# -# void -# cpu_switchto(struct proc *oldproc = r0, struct proc *newproc = r1); -# - -#define CURPROC _cpu_info_store + CI_CURPROC - -JSBENTRY(__cpu_switchto) - svpctx - - movb $SONPROC,P_STAT(r1) # p->p_stat = SONPROC - movl r1, CURPROC # set new process running - - movl P_ADDR(r1),r0 # Get pointer to new pcb. - addl3 r0,$IFTRAP,pcbtrap # Save for copy* functions. - - # inline kvtophys - extzv $9,$21,r0,r1 # extract offset - movl *_Sysmap[r1],r2 # get pte - ashl $9,r2,r3 # shift to get phys address. - -# -# Do the actual process switch. pc + psl are already on stack, from -# the beginning of this routine. -# - mtpr r3,$PR_PCBB - - pushl CURPROC - calls $1, _C_LABEL(pmap_activate) - - ldpctx - rei - -# -# copy/fetch/store routines. -# - .align 2,1 -ENTRY(copyin, R2|R3|R4|R5|R6) - movl 4(ap), r0 - blss 3f # kernel space - movl 8(ap), r1 - brb 2f - -ENTRY(copyout, R2|R3|R4|R5|R6) - movl 8(ap), r1 - blss 3f # kernel space - movl 4(ap), r0 -2: movab 1f,*pcbtrap - movzwl 12(ap), r2 - movzwl 14(ap), r6 - - movc3 r2, (r0), (r1) - - tstl r6 - bleq 1f -0: movb (r1)+, (r3)+ - movc3 $0xffff, (r1), (r3) - sobgtr r6,0b - -1: clrl *pcbtrap - ret - -3: movl $EFAULT, r0 - ret - -/* kcopy: just like bcopy, except return -1 upon failure */ -ENTRY(kcopy,R2|R3|R4|R5|R6) - movl *pcbtrap,-(sp) - movab 2f,*pcbtrap - movl 4(ap), r0 - movl 8(ap), r1 - movzwl 12(ap), r2 - movzwl 14(ap), r6 - - movc3 r2, (r0), (r1) - - tstl r6 - bleq 1f -0: movb (r1)+, (r3)+ - movc3 $0xffff, (r1), (r3) - sobgtr r6, 0b - - /* - * If there is a failure, trap.c will set r1 to -1, and jump - * to the following 2. If not, we return 0. We duplicate a - * minuscule amount of code in the interest of speed; movc3 - * sets r0 to 0 anyway. - */ -1: - movl (sp)+,*pcbtrap - ret - -2: movl (sp)+,*pcbtrap - movl r1,r0 - ret - -ENTRY(copyinstr,0) - tstl 4(ap) # is from a kernel address? - bgeq 8f # no, continue - -6: movl $EFAULT,r0 - ret - -ENTRY(copyoutstr,0) - tstl 8(ap) # is to a kernel address? - bgeq 8f # no, continue - brb 6b - -ENTRY(copystr,0) -8: movl 4(ap),r4 # from - movl 8(ap),r5 # to - movl 16(ap),r3 # copied - movl 12(ap),r2 # len - - bneq 1f # nothing to copy? - movl $ENAMETOOLONG,r0 - tstl r3 - beql 0f - movl $0,(r3) -0: ret - -1: movab 2f,*pcbtrap - -/* - * This routine consists of two parts: One is for MV2 that doesn't have - * locc in hardware, the other is a fast version with locc. But because - * locc only handles <64k strings, we default to the slow version if the - * string is longer. - */ - cmpl _vax_cputype,$VAX_TYP_UV2 - bneq 4f # Check if locc emulated - -9: movl r2,r0 -7: movb (r4)+,(r5)+ - beql 6f # end of string - sobgtr r0,7b # no null byte in the len first bytes? - brb 1f - -6: tstl r3 - beql 5f - incl r2 - subl3 r0,r2,(r3) -5: clrl r0 - clrl *pcbtrap - ret - -4: cmpl r2,$65535 # maxlen < 64k? - blss 8f # then use fast code. - - locc $0,$65535,(r4) # is strlen < 64k? - beql 9b # No, use slow code - subl3 r0,$65535,r1 # Get string len - brb 0f # do the copy - -8: locc $0,r2,(r4) # check for null byte - beql 1f - - subl3 r0,r2,r1 # Calculate len to copy -0: incl r1 # Copy null byte also - tstl r3 - beql 3f - movl r1,(r3) # save len copied -3: movc3 r1,(r4),(r5) - brb 4f - -1: movl $ENAMETOOLONG,r0 -2: movab 4f,*pcbtrap # if we fault again, don't resume there - subl3 8(ap),r5,r1 # did we write to the string? - beql 3f - decl r5 -3: movb $0,(r5) # null terminate the output string - tstl r3 - beql 4f - incl r1 # null byte accounts for outlen... - movl r1,(r3) # save len copied -4: clrl *pcbtrap - ret - -# -# data department -# - .data - -_memtest: .long 0 ; .globl _memtest # Memory test in progress. -pcbtrap: .long 0x800001fc; .globl pcbtrap # Safe place -_bootdev: .long 0; .globl _bootdev |