diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/lib/libkern/Makefile | 10 | ||||
-rw-r--r-- | sys/lib/libkern/arch/alpha/Makefile.inc | 4 | ||||
-rw-r--r-- | sys/lib/libkern/arch/alpha/bzero.S | 110 | ||||
-rw-r--r-- | sys/lib/libkern/arch/alpha/divrem.m4 | 55 | ||||
-rw-r--r-- | sys/lib/libkern/arch/ns32k/Makefile.inc | 2 | ||||
-rw-r--r-- | sys/lib/libkern/arch/ns32k/setjmp.S | 70 | ||||
-rw-r--r-- | sys/lib/libkern/quad.h | 2 |
7 files changed, 225 insertions, 28 deletions
diff --git a/sys/lib/libkern/Makefile b/sys/lib/libkern/Makefile index 8282d8b9100..af57b69848e 100644 --- a/sys/lib/libkern/Makefile +++ b/sys/lib/libkern/Makefile @@ -1,10 +1,14 @@ -# $NetBSD: Makefile,v 1.23 1995/10/07 09:56:54 mycroft Exp $ +# $NetBSD: Makefile,v 1.24 1995/10/20 01:10:06 cgd Exp $ LIB= kern NOPIC= DIR=${KERNREL}${KERNDIR} +CC= ${KERNCC} +CFLAGS= -I${DIR}/arch/${MACHINE_ARCH} \ + ${KERNCFLAGS:S/-D_KERNEL//:S@-I.@-I${KERNREL}.@g} + .if exists (${DIR}/arch/${MACHINE_ARCH}/Makefile.inc) .PATH: ${DIR}/arch/${MACHINE_ARCH} .include "${DIR}/arch/${MACHINE_ARCH}/Makefile.inc" @@ -12,10 +16,6 @@ DIR=${KERNREL}${KERNDIR} .PATH: ${DIR} -CC = ${KERNCC} -CFLAGS += -I${DIR}/arch/${MACHINE_ARCH} \ - ${KERNCFLAGS:S/-D_KERNEL//:S@-I.@-I${KERNREL}.@g} - .if (${MACHINE_ARCH} != "alpha") # Quad support SRCS+= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \ diff --git a/sys/lib/libkern/arch/alpha/Makefile.inc b/sys/lib/libkern/arch/alpha/Makefile.inc index 648b0a9ebb8..c78b3c0a8fa 100644 --- a/sys/lib/libkern/arch/alpha/Makefile.inc +++ b/sys/lib/libkern/arch/alpha/Makefile.inc @@ -1,7 +1,7 @@ -# $Id: Makefile.inc,v 1.1 1995/10/18 08:52:51 deraadt Exp $ +# $NetBSD: Makefile.inc,v 1.3 1995/10/20 01:15:37 cgd Exp $ SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \ - bcmp.c bzero.c ffs.c strcat.c strcmp.c strcpy.c strlen.c strncmp.c \ + bcmp.c bzero.S ffs.c strcat.c strcmp.c strcpy.c strlen.c strncmp.c \ strncpy.c scanc.c skpc.c locc.c htonl.c htons.c ntohl.c ntohs.c \ random.c diff --git a/sys/lib/libkern/arch/alpha/bzero.S b/sys/lib/libkern/arch/alpha/bzero.S new file mode 100644 index 00000000000..3bf1e75a9f8 --- /dev/null +++ b/sys/lib/libkern/arch/alpha/bzero.S @@ -0,0 +1,110 @@ +/* $NetBSD: bzero.S,v 1.1 1995/10/20 01:16:02 cgd Exp $ */ + +/* + * Copyright (c) 1995 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Trevor Blackwell + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include "DEFS.h" + +LEAF(bzero,2) + ble a1,bzero_done + bic a1,63,t3 /* t3 is # bytes to do 64 bytes at a time */ + + /* If nothing in first word, ignore it */ + subq zero,a0,t0 + and t0,7,t0 /* t0 = (0-size)%8 */ + beq t0,bzero_nostart1 + + cmpult a1,t0,t1 /* if size > size%8 goto noshort */ + beq t1,bzero_noshort + + /* + * The whole thing is less than a word. + * Mask off 1..7 bytes, and finish. + */ + ldq_u t2,0(a0) + lda t0,-1(zero) /* t0=-1 */ + mskql t0,a1,t0 /* Get ff in bytes (a0%8)..((a0+a1-1)%8) */ + insql t0,a0,t0 + bic t2,t0,t2 /* zero those bytes in word */ + stq_u t2,0(a0) + RET + +bzero_noshort: + /* Handle the first partial word */ + ldq_u t2,0(a0) + subq a1,t0,a1 + mskql t2,a0,t2 /* zero bytes (a0%8)..7 in word */ + stq_u t2,0(a0) + + addq a0,t0,a0 /* round a0 up to next word */ + bic a1,63,t3 /* recalc t3 (# bytes to do 64 bytes at a + time) */ + +bzero_nostart1: + /* + * Loop, zeroing 64 bytes at a time + */ + beq t3,bzero_lp_done +bzero_lp: + stq zero,0(a0) + stq zero,8(a0) + stq zero,16(a0) + stq zero,24(a0) + subq t3,64,t3 + stq zero,32(a0) + stq zero,40(a0) + stq zero,48(a0) + stq zero,56(a0) + addq a0,64,a0 + bne t3,bzero_lp + +bzero_lp_done: + /* + * Handle the last 0..7 words. + * We mask off the low bits, so we don't need an extra + * compare instruction for the loop (just a bne. heh-heh) + */ + and a1,0x38,t4 + beq t4,bzero_finish_lp_done +bzero_finish_lp: + stq zero,0(a0) + subq t4,8,t4 + addq a0,8,a0 + bne t4,bzero_finish_lp + + /* Do the last partial word */ +bzero_finish_lp_done: + and a1,7,t5 /* 0..7 bytes left */ + beq t5,bzero_done /* mskqh won't change t0 if t5==0, but I + don't want to touch, say, a new VM page */ + ldq t0,0(a0) + mskqh t0,t5,t0 + stq t0,0(a0) +bzero_done: + RET + + END(bzero) diff --git a/sys/lib/libkern/arch/alpha/divrem.m4 b/sys/lib/libkern/arch/alpha/divrem.m4 index dd33e37b527..f0a9a10409a 100644 --- a/sys/lib/libkern/arch/alpha/divrem.m4 +++ b/sys/lib/libkern/arch/alpha/divrem.m4 @@ -1,4 +1,4 @@ -/* $NetBSD: divrem.m4,v 1.2 1995/03/03 01:14:11 cgd Exp $ */ +/* $NetBSD: divrem.m4,v 1.3 1995/10/20 00:53:28 cgd Exp $ */ /* * Copyright (c) 1994, 1995 Carnegie-Mellon University. @@ -40,7 +40,7 @@ * M4 Parameters * NAME name of function to generate * OP OP=div: t10 / t11 -> t12; OP=rem: t10 % t11 -> t12 - * S S=true: signed; S=false: unsigned [XXX NOT YET] + * S S=true: signed; S=false: unsigned * WORDSIZE total number of bits */ @@ -52,50 +52,65 @@ define(BIT, `t0') define(I, `t1') define(CC, `t2') define(T_0, `t3') -ifelse(S, `true', `define(SIGN, `t4')') +ifelse(S, `true', `define(NEG, `t4')') #include "DEFS.h" LEAF(NAME, 0) /* XXX */ - lda sp, -48(sp) + lda sp, -64(sp) stq BIT, 0(sp) stq I, 8(sp) stq CC, 16(sp) stq T_0, 24(sp) ifelse(S, `true', -` stq SIGN, 32(sp)') +` stq NEG, 32(sp)') + stq A, 40(sp) + stq B, 48(sp) mov zero, RESULT /* Initialize result to zero */ ifelse(S, `true', ` /* Compute sign of result. If either is negative, this is easy. */ - or A, B, SIGN /* not the sign, but... */ - bgt SIGN, Ldoit /* neither negative? do it! */ + or A, B, NEG /* not the sign, but... */ + srl NEG, WORDSIZE - 1, NEG /* rather, or of high bits */ + blbc NEG, Ldoit /* neither negative? do it! */ ifelse(OP, `div', -` xor A, B, SIGN /* THIS is the sign! */ -', ` mov A, SIGN /* sign follows A. */ +` xor A, B, NEG /* THIS is the sign! */ +', ` mov A, NEG /* sign follows A. */ ') - bge A, LnegB /* see if A is negative */ + srl NEG, WORDSIZE - 1, NEG /* make negation the low bit. */ + + srl A, WORDSIZE - 1, I /* is A negative? */ + blbc I, LnegB /* no. */ /* A is negative; flip it. */ +ifelse(WORDSIZE, `32', ` + /* top 32 bits may be random junk */ + zap A, 0xf0, A +') subq zero, A, A - bge B, Ldoit /* see if B is negative */ + srl B, WORDSIZE - 1, I /* is B negative? */ + blbc I, Ldoit /* no. */ LnegB: /* B is definitely negative, no matter how we got here. */ +ifelse(WORDSIZE, `32', ` + /* top 32 bits may be random junk */ + zap B, 0xf0, B +') subq zero, B, B Ldoit: -', ` +') ifelse(WORDSIZE, `32', ` /* - * Clear the top 32 bits of each operand, as the compiler may - * have sign extended them, if the 31st bit was set. + * Clear the top 32 bits of each operand, as they may + * sign extension (if negated above), or random junk. */ zap A, 0xf0, A zap B, 0xf0, B -')' ) +') /* kill the special cases. */ - beq B, Ldotrap /* division by zero! XXX */ + beq B, Ldotrap /* division by zero! */ 1: cmpult A, B, CC /* A < B? */ /* RESULT is already zero, from above. A is untouched. */ @@ -157,7 +172,7 @@ ifelse(S, `true', ` /* Check to see if we should negate it. */ subqv zero, RESULT, T_0 - cmovlt SIGN, T_0, RESULT + cmovlbs NEG, T_0, RESULT ') ldq BIT, 0(sp) @@ -165,8 +180,10 @@ ifelse(S, `true', ldq CC, 16(sp) ldq T_0, 24(sp) ifelse(S, `true', -` ldq SIGN, 32(sp)') - lda sp, 48(sp) +` ldq NEG, 32(sp)') + ldq A, 40(sp) + ldq B, 48(sp) + lda sp, 64(sp) ret zero, (t9), 1 Ldotrap: diff --git a/sys/lib/libkern/arch/ns32k/Makefile.inc b/sys/lib/libkern/arch/ns32k/Makefile.inc index d4398986a7b..26eb4002710 100644 --- a/sys/lib/libkern/arch/ns32k/Makefile.inc +++ b/sys/lib/libkern/arch/ns32k/Makefile.inc @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.5.2.1 1995/10/13 20:29:29 phil Exp $ +# $NetBSD: Makefile.inc,v 1.6 1995/11/30 01:00:10 jtc Exp $ SRCS+= __main.c imax.c imin.c lmax.c lmin.c max.c min.c ulmax.c ulmin.c \ bcmp.c ffs.c strcat.c strcmp.c strcpy.c strlen.c strncmp.c strncpy.c \ diff --git a/sys/lib/libkern/arch/ns32k/setjmp.S b/sys/lib/libkern/arch/ns32k/setjmp.S new file mode 100644 index 00000000000..dfca3d55691 --- /dev/null +++ b/sys/lib/libkern/arch/ns32k/setjmp.S @@ -0,0 +1,70 @@ +/* $NetBSD: setjmp.S,v 1.3 1995/11/30 01:00:12 jtc Exp $ */ + +/* + * Copyright (c) 1992 Helsinki University of Technology + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN + * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY + * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE + * USE OF THIS SOFTWARE. + */ +/* + * HISTORY + * 29-Apr-92 Johannes Helander (jvh) at Helsinki University of Technology + * Created. + */ + +#include <machine/asm.h> +#include <machine/jmpbuf.h> + +ENTRY(setjmp) + movqd 0, tos + bsr EX(sigblock) + adjspb -4 + movd 4(sp), r2 /* jmp_buf */ + movd 0(sp), JMP_BUF_PC(r2) /* pc of caller */ + movd r0, JMP_BUF_SIGMASK(r2) /* save mask */ + + sprd sp, JMP_BUF_SP(r2) + sprd fp, JMP_BUF_FP(r2) + sprd sb, JMP_BUF_SB(r2) + movd r3, JMP_BUF_R3(r2) /* save registers r3-r7 */ + movd r4, JMP_BUF_R4(r2) + movd r5, JMP_BUF_R5(r2) + movd r6, JMP_BUF_R6(r2) + movd r7, JMP_BUF_R7(r2) + + movqd 0, r0 + ret 0 + +ENTRY(longjmp) + movd 4(sp),r2 /* jmp_buf */ + movd JMP_BUF_SIGMASK(r2), tos /* restore mask */ + bsr EX(sigsetmask) + adjspb -4 + movd 4(sp), r2 /* jmp_buf */ + movd 8(sp), r0 /* value */ + + lprd sp, JMP_BUF_SP(r2) + lprd fp, JMP_BUF_FP(r2) + lprd sb, JMP_BUF_SB(r2) + movd JMP_BUF_R3(r2), r3 /* load registers r3-r7 */ + movd JMP_BUF_R4(r2), r4 + movd JMP_BUF_R5(r2), r5 + movd JMP_BUF_R6(r2), r6 + movd JMP_BUF_R7(r2), r7 + movd JMP_BUF_PC(r2), 0(sp) /* patch return pc */ + + cmpqd 0, r0 + bne nonzero + movqd 1, r0 +nonzero: + ret 0 + diff --git a/sys/lib/libkern/quad.h b/sys/lib/libkern/quad.h index 2d4d2523c51..f7eea7a31ec 100644 --- a/sys/lib/libkern/quad.h +++ b/sys/lib/libkern/quad.h @@ -1,4 +1,4 @@ -/* $NetBSD: quad.h,v 1.4.2.1 1995/10/12 15:17:26 jtc Exp $ */ +/* $NetBSD: quad.h,v 1.5 1995/10/12 15:13:58 jtc Exp $ */ /*- * Copyright (c) 1992, 1993 |