From owner-p4-projects@FreeBSD.ORG Mon Oct 23 10:06:11 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5E5EE16A5B1; Mon, 23 Oct 2006 10:06:11 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1B1DA16A598 for ; Mon, 23 Oct 2006 10:06:11 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 47C2F43D99 for ; Mon, 23 Oct 2006 10:05:36 +0000 (GMT) (envelope-from gonzo@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k9NA5aQR005317 for ; Mon, 23 Oct 2006 10:05:36 GMT (envelope-from gonzo@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k9NA5a7M005309 for perforce@freebsd.org; Mon, 23 Oct 2006 10:05:36 GMT (envelope-from gonzo@FreeBSD.org) Date: Mon, 23 Oct 2006 10:05:36 GMT Message-Id: <200610231005.k9NA5a7M005309@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gonzo@FreeBSD.org using -f From: Oleksandr Tymoshenko To: Perforce Change Reviews Cc: Subject: PERFORCE change 108299 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Oct 2006 10:06:11 -0000 http://perforce.freebsd.org/chv.cgi?CH=108299 Change 108299 by gonzo@gonzo_hq on 2006/10/23 10:05:12 o Implement functions from "copystr" family. Affected files ... .. //depot/projects/mips2/src/sys/mips/mips/copystr.S#4 edit Differences ... ==== //depot/projects/mips2/src/sys/mips/mips/copystr.S#4 (text+ko) ==== @@ -34,14 +34,13 @@ #include /* - * XXXMIPS: Implement these routines - */ -/* * copystr(9) * int copystr(const void *src, void *dst, size_t len, * size_t *done) */ ENTRY(copystr) + .set noreorder + .set noat move v0, zero beqz a2, 2f move t1, zero @@ -62,13 +61,88 @@ sw t1, 0(a3) 4: jr ra nop + .set reorder + .set at END(copystr) - -ENTRY(copyinstr) - break +/* + * int copyinstr(void *uaddr, void *kaddr, size_t maxlen, size_t *lencopied) + * Copy a NIL-terminated string, at most maxlen characters long, from the + * user's address space. Return the number of characters copied (including + * the NIL) in *lencopied. If the string is too long, return ENAMETOOLONG; + * else return 0 or EFAULT. + */ +LEAF(copyinstr) + .set noreorder + .set noat + lw t2, pcpup + lw v1, PC_CURPCB(t2) + la v0, _C_LABEL(copystrerr) + blt a0, zero, _C_LABEL(copystrerr) + sw v0, PCB_ONFAULT(v1) + move t0, a2 + beq a2, zero, 4f +1: + lbu v0, 0(a0) + subu a2, a2, 1 + beq v0, zero, 2f + sb v0, 0(a1) + addu a0, a0, 1 + bne a2, zero, 1b + addu a1, a1, 1 +4: + li v0, ENAMETOOLONG +2: + beq a3, zero, 3f + subu a2, t0, a2 + sw a2, 0(a3) +3: + j ra # v0 is 0 or ENAMETOOLONG + sw zero, PCB_ONFAULT(v1) + .set reorder + .set at END(copyinstr) -ENTRY(copyoutstr) - break +/* + * int copyoutstr(void *uaddr, void *kaddr, size_t maxlen, size_t *lencopied); + * Copy a NIL-terminated string, at most maxlen characters long, into the + * user's address space. Return the number of characters copied (including + * the NIL) in *lencopied. If the string is too long, return ENAMETOOLONG; + * else return 0 or EFAULT. + */ +LEAF(copyoutstr) + .set noreorder + .set noat + lw t2, pcpup + lw v1, PC_CURPCB(t2) + la v0, _C_LABEL(copystrerr) + blt a1, zero, _C_LABEL(copystrerr) + sw v0, PCB_ONFAULT(v1) + move t0, a2 + beq a2, zero, 4f +1: + lbu v0, 0(a0) + subu a2, a2, 1 + beq v0, zero, 2f + sb v0, 0(a1) + addu a0, a0, 1 + bne a2, zero, 1b + addu a1, a1, 1 +4: + li v0, ENAMETOOLONG +2: + beq a3, zero, 3f + subu a2, t0, a2 + sw a2, 0(a3) +3: + j ra # v0 is 0 or ENAMETOOLONG + sw zero, PCB_ONFAULT(v1) + .set reorder + .set at END(copyoutstr) + +LEAF(copystrerr) + sw zero, PCB_ONFAULT(v1) + j ra + li v0, EFAULT # return EFAULT +END(copystrerr)