From owner-p4-projects Fri Oct 4 15:36:31 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 069D737B404; Fri, 4 Oct 2002 15:36:21 -0700 (PDT) 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 616AF37B401 for ; Fri, 4 Oct 2002 15:36:20 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id BDDAB43E3B for ; Fri, 4 Oct 2002 15:36:19 -0700 (PDT) (envelope-from peter@freebsd.org) Received: from freefall.freebsd.org (perforce@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id g94MaJCo083964 for ; Fri, 4 Oct 2002 15:36:19 -0700 (PDT) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id g94MaJt3083961 for perforce@freebsd.org; Fri, 4 Oct 2002 15:36:19 -0700 (PDT) Date: Fri, 4 Oct 2002 15:36:19 -0700 (PDT) Message-Id: <200210042236.g94MaJt3083961@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm Subject: PERFORCE change 18684 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=18684 Change 18684 by peter@peter_daintree on 2002/10/04 15:35:20 integ i386_hammer, minus the temporary fpu hacks. Affected files ... .. //depot/projects/hammer/sys/x86_64/include/bus_dma.h#2 integrate .. //depot/projects/hammer/sys/x86_64/include/setjmp.h#2 integrate .. //depot/projects/hammer/sys/x86_64/include/ucontext.h#3 integrate .. //depot/projects/hammer/sys/x86_64/x86_64/busdma_machdep.c#2 integrate .. //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#24 integrate .. //depot/projects/hammer/sys/x86_64/x86_64/sys_machdep.c#7 integrate Differences ... ==== //depot/projects/hammer/sys/x86_64/include/bus_dma.h#2 (text+ko) ==== @@ -67,7 +67,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* $FreeBSD: src/sys/i386/include/bus_dma.h,v 1.15 2001/10/06 16:27:21 nyan Exp $ */ +/* $FreeBSD: src/sys/i386/include/bus_dma.h,v 1.16 2002/10/04 20:40:37 sam Exp $ */ #ifndef _I386_BUS_DMA_H_ #define _I386_BUS_DMA_H_ @@ -203,6 +203,29 @@ void *callback_arg, int flags); /* + * Like bus_dmamap_callback but includes map size in bytes. This is + * defined as a separate interface to maintain compatiiblity for users + * of bus_dmamap_callback_t--at some point these interfaces should be merged. + */ +typedef void bus_dmamap_callback2_t(void *, bus_dma_segment_t *, int, bus_size_t, int); +/* + * Like bus_dmamap_load but for mbufs. Note the use of the + * bus_dmamap_callback2_t interface. + */ +int bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, + struct mbuf *mbuf, + bus_dmamap_callback2_t *callback, void *callback_arg, + int flags); +/* + * Like bus_dmamap_load but for uios. Note the use of the + * bus_dmamap_callback2_t interface. + */ +int bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, + struct uio *ui, + bus_dmamap_callback2_t *callback, void *callback_arg, + int flags); + +/* * Perform a syncronization operation on the given map. */ void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t); ==== //depot/projects/hammer/sys/x86_64/include/setjmp.h#2 (text+ko) ==== @@ -1,5 +1,4 @@ -/* $FreeBSD: src/sys/i386/include/setjmp.h,v 1.5 2000/10/06 11:53:31 bde Exp $ */ -/* +/*- * Copyright (c) 1998 John Birrell . * All rights reserved. * @@ -30,8 +29,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * + * $FreeBSD: src/sys/i386/include/setjmp.h,v 1.6 2002/10/04 22:10:06 mike Exp $ */ +#ifndef _MACHINE_SETJMP_H_ +#define _MACHINE_SETJMP_H_ + #define _JBLEN 11 /* Size of the jmp_buf on x86. */ /* @@ -40,7 +43,9 @@ * internally to avoid some run-time errors for mismatches. */ #ifndef _ANSI_SOURCE -typedef struct _sigjmp_buf { int _sjb[_JBLEN + 1]; } sigjmp_buf[1]; -#endif /* not ANSI */ +typedef struct _sigjmp_buf { int _sjb[_JBLEN + 1]; } sigjmp_buf[1]; +#endif + +typedef struct _jmp_buf { int _jb[_JBLEN + 1]; } jmp_buf[1]; -typedef struct _jmp_buf { int _jb[_JBLEN + 1]; } jmp_buf[1]; +#endif /* !_MACHINE_SETJMP_H_ */ ==== //depot/projects/hammer/sys/x86_64/include/ucontext.h#3 (text+ko) ==== @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/i386/include/ucontext.h,v 1.6 2002/09/16 19:25:41 mini Exp $ + * $FreeBSD: src/sys/i386/include/ucontext.h,v 1.7 2002/10/04 14:50:55 deischen Exp $ */ #ifndef _MACHINE_UCONTEXT_H_ @@ -58,13 +58,13 @@ int mc_ss; int mc_len; /* sizeof(mcontext_t) */ -#define _MC_FPFMT_NODEV 0 /* device not present or configured */ -#define _MC_FPFMT_387 1 -#define _MC_FPFMT_XMM 2 +#define _MC_FPFMT_NODEV 0x10000 /* device not present or configured */ +#define _MC_FPFMT_387 0x10001 +#define _MC_FPFMT_XMM 0x10002 int mc_fpformat; -#define _MC_FPOWNED_NONE 0 /* FP state not used */ -#define _MC_FPOWNED_FPU 1 /* FP state came from FPU */ -#define _MC_FPOWNED_PCB 2 /* FP state came from PCB */ +#define _MC_FPOWNED_NONE 0x20000 /* FP state not used */ +#define _MC_FPOWNED_FPU 0x20001 /* FP state came from FPU */ +#define _MC_FPOWNED_PCB 0x20002 /* FP state came from PCB */ int mc_ownedfp; int mc_spare1[1]; /* align next field to 16 bytes */ int mc_fpstate[128]; /* must be multiple of 16 bytes */ ==== //depot/projects/hammer/sys/x86_64/x86_64/busdma_machdep.c#2 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/i386/i386/busdma_machdep.c,v 1.27 2002/08/21 23:39:52 archie Exp $ + * $FreeBSD: src/sys/i386/i386/busdma_machdep.c,v 1.28 2002/10/04 20:40:37 sam Exp $ */ #include @@ -34,9 +34,12 @@ #include #include #include +#include +#include #include #include +#include #include #include @@ -494,6 +497,209 @@ } /* + * Utility function to load a linear buffer. lastaddrp holds state + * between invocations (for multiple-buffer loads). segp contains + * the starting segment on entrace, and the ending segment on exit. + * first indicates if this is the first invocation of this function. + */ +static int +_bus_dmamap_load_buffer(bus_dma_tag_t dmat, + bus_dma_segment_t segs[], + void *buf, bus_size_t buflen, + struct thread *td, + int flags, + vm_offset_t *lastaddrp, + int *segp, + int first) +{ + bus_size_t sgsize; + bus_addr_t curaddr, lastaddr, baddr, bmask; + vm_offset_t vaddr = (vm_offset_t)buf; + int seg; + pmap_t pmap; + + if (td != NULL) + pmap = vmspace_pmap(td->td_proc->p_vmspace); + else + pmap = NULL; + + lastaddr = *lastaddrp; + bmask = ~(dmat->boundary - 1); + + for (seg = *segp; buflen > 0 ; ) { + /* + * Get the physical address for this segment. + */ + if (pmap) + curaddr = pmap_extract(pmap, vaddr); + else + curaddr = pmap_kextract(vaddr); + + /* + * Compute the segment size, and adjust counts. + */ + sgsize = PAGE_SIZE - ((u_long)curaddr & PAGE_MASK); + if (buflen < sgsize) + sgsize = buflen; + + /* + * Make sure we don't cross any boundaries. + */ + if (dmat->boundary > 0) { + baddr = (curaddr + dmat->boundary) & bmask; + if (sgsize > (baddr - curaddr)) + sgsize = (baddr - curaddr); + } + + /* + * Insert chunk into a segment, coalescing with + * previous segment if possible. + */ + if (first) { + segs[seg].ds_addr = curaddr; + segs[seg].ds_len = sgsize; + first = 0; + } else { + if (curaddr == lastaddr && + (segs[seg].ds_len + sgsize) <= dmat->maxsegsz && + (dmat->boundary == 0 || + (segs[seg].ds_addr & bmask) == (curaddr & bmask))) + segs[seg].ds_len += sgsize; + else { + if (++seg >= dmat->nsegments) + break; + segs[seg].ds_addr = curaddr; + segs[seg].ds_len = sgsize; + } + } + + lastaddr = curaddr + sgsize; + vaddr += sgsize; + buflen -= sgsize; + } + + *segp = seg; + *lastaddrp = lastaddr; + + /* + * Did we fit? + */ + return (buflen != 0 ? EFBIG : 0); /* XXX better return value here? */ +} + +/* + * Like _bus_dmamap_load(), but for mbufs. + */ +int +bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, + struct mbuf *m0, + bus_dmamap_callback2_t *callback, void *callback_arg, + int flags) +{ +#ifdef __GNUC__ + bus_dma_segment_t dm_segments[dmat->nsegments]; +#else + bus_dma_segment_t dm_segments[BUS_DMAMAP_NSEGS]; +#endif + int nsegs, error; + + KASSERT(dmat->lowaddr >= ptoa(Maxmem) || map != NULL, + ("bus_dmamap_load_mbuf: No support for bounce pages!")); + KASSERT(m0->m_flags & M_PKTHDR, + ("bus_dmamap_load_mbuf: no packet header")); + + nsegs = 0; + error = 0; + if (m0->m_pkthdr.len <= dmat->maxsize) { + int first = 1; + vm_offset_t lastaddr = 0; + struct mbuf *m; + + for (m = m0; m != NULL && error == 0; m = m->m_next) { + error = _bus_dmamap_load_buffer(dmat, + dm_segments, + m->m_data, m->m_len, + NULL, flags, &lastaddr, &nsegs, first); + first = 0; + } + } else { + error = EINVAL; + } + + if (error) { + /* force "no valid mappings" in callback */ + (*callback)(callback_arg, dm_segments, 0, 0, error); + } else { + (*callback)(callback_arg, dm_segments, + nsegs+1, m0->m_pkthdr.len, error); + } + return (error); +} + +/* + * Like _bus_dmamap_load(), but for uios. + */ +int +bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, + struct uio *uio, + bus_dmamap_callback2_t *callback, void *callback_arg, + int flags) +{ + vm_offset_t lastaddr; +#ifdef __GNUC__ + bus_dma_segment_t dm_segments[dmat->nsegments]; +#else + bus_dma_segment_t dm_segments[BUS_DMAMAP_NSEGS]; +#endif + int nsegs, error, first, i; + bus_size_t resid; + struct iovec *iov; + struct thread *td = NULL; + + KASSERT(dmat->lowaddr >= ptoa(Maxmem) || map != NULL, + ("bus_dmamap_load_uio: No support for bounce pages!")); + + resid = uio->uio_resid; + iov = uio->uio_iov; + + if (uio->uio_segflg == UIO_USERSPACE) { + td = uio->uio_td; + KASSERT(td != NULL, + ("bus_dmamap_load_uio: USERSPACE but no proc")); + } + + nsegs = 0; + error = 0; + first = 1; + for (i = 0; i < uio->uio_iovcnt && resid != 0 && !error; i++) { + /* + * Now at the first iovec to load. Load each iovec + * until we have exhausted the residual count. + */ + bus_size_t minlen = + resid < iov[i].iov_len ? resid : iov[i].iov_len; + caddr_t addr = (caddr_t) iov[i].iov_base; + + error = _bus_dmamap_load_buffer(dmat, + dm_segments, + addr, minlen, + td, flags, &lastaddr, &nsegs, first); + first = 0; + + resid -= minlen; + } + + if (error) { + /* force "no valid mappings" in callback */ + (*callback)(callback_arg, dm_segments, 0, 0, error); + } else { + (*callback)(callback_arg, dm_segments, + nsegs+1, uio->uio_resid, error); + } + return (error); +} + +/* * Release the mapping held by map. */ void ==== //depot/projects/hammer/sys/x86_64/x86_64/machdep.c#24 (text+ko) ==== @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.539 2002/09/30 07:02:22 obrien Exp $ + * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.540 2002/10/04 14:50:50 deischen Exp $ */ #include "opt_atalk.h" ==== //depot/projects/hammer/sys/x86_64/x86_64/sys_machdep.c#7 (text+ko) ==== @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * from: @(#)sys_machdep.c 5.5 (Berkeley) 1/19/91 - * $FreeBSD: src/sys/i386/i386/sys_machdep.c,v 1.73 2002/09/28 22:44:45 peter Exp $ + * $FreeBSD: src/sys/i386/i386/sys_machdep.c,v 1.74 2002/10/04 20:19:36 jhb Exp $ * */ @@ -510,7 +510,7 @@ /* Fill in range */ savecrit = intr_disable(); - bcopy(uap->descs, + bcopy(descs, &((union descriptor *)(pldt->ldt_base))[uap->start], uap->num * sizeof(union descriptor)); td->td_retval[0] = uap->start; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message