From owner-p4-projects@FreeBSD.ORG Thu Jul 31 22:34:54 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 365DB37B404; Thu, 31 Jul 2003 22:34:54 -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 D7E1D37B401 for ; Thu, 31 Jul 2003 22:34:53 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id D247143FA3 for ; Thu, 31 Jul 2003 22:34:52 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h715Yq0U045218 for ; Thu, 31 Jul 2003 22:34:52 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h715YqJA045215 for perforce@freebsd.org; Thu, 31 Jul 2003 22:34:52 -0700 (PDT) Date: Thu, 31 Jul 2003 22:34:52 -0700 (PDT) Message-Id: <200308010534.h715YqJA045215@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 35320 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Aug 2003 05:34:55 -0000 http://perforce.freebsd.org/chv.cgi?CH=35320 Change 35320 by marcel@marcel_nfs on 2003/07/31 22:34:02 IFC @35316 Affected files ... .. //depot/projects/uart/conf/files.alpha#4 integrate .. //depot/projects/uart/conf/files.amd64#2 integrate .. //depot/projects/uart/conf/files.i386#4 integrate .. //depot/projects/uart/conf/files.ia64#4 integrate .. //depot/projects/uart/ddb/db_command.c#2 integrate .. //depot/projects/uart/ddb/db_output.c#2 integrate .. //depot/projects/uart/ddb/db_ps.c#3 integrate .. //depot/projects/uart/ddb/ddb.h#2 integrate .. //depot/projects/uart/dev/amd/amd.c#3 integrate .. //depot/projects/uart/dev/firewire/firewire.h#2 integrate .. //depot/projects/uart/dev/firewire/firewirereg.h#2 integrate .. //depot/projects/uart/dev/firewire/fwdev.c#3 integrate .. //depot/projects/uart/dev/firewire/fwohci.c#5 integrate .. //depot/projects/uart/dev/firewire/if_fwe.c#3 integrate .. //depot/projects/uart/dev/firewire/sbp.c#6 integrate .. //depot/projects/uart/dev/hfa/fore_aali.h#2 integrate .. //depot/projects/uart/dev/hfa/fore_command.c#2 integrate .. //depot/projects/uart/dev/hfa/fore_init.c#2 integrate .. //depot/projects/uart/dev/hfa/fore_intr.c#2 integrate .. //depot/projects/uart/dev/hfa/fore_output.c#2 integrate .. //depot/projects/uart/dev/hfa/fore_var.h#2 integrate .. //depot/projects/uart/dev/hfa/fore_vcm.c#2 integrate .. //depot/projects/uart/dev/hfa/hfa_freebsd.c#2 integrate .. //depot/projects/uart/dev/hfa/hfa_freebsd.h#2 integrate .. //depot/projects/uart/dev/pci/pci.c#3 integrate .. //depot/projects/uart/dev/pdq/if_fea.c#2 integrate .. //depot/projects/uart/dev/ppc/ppc.c#2 integrate .. //depot/projects/uart/dev/ppc/ppc_puc.c#1 branch .. //depot/projects/uart/dev/ppc/ppcvar.h#1 branch .. //depot/projects/uart/dev/puc/puc.c#5 integrate .. //depot/projects/uart/i386/i386/sys_machdep.c#4 integrate .. //depot/projects/uart/isa/ppc.c#2 delete .. //depot/projects/uart/isa/ppcreg.h#2 delete .. //depot/projects/uart/kern/kern_ktr.c#2 integrate .. //depot/projects/uart/kern/kern_mutex.c#4 integrate .. //depot/projects/uart/kern/subr_witness.c#3 integrate .. //depot/projects/uart/kern/sys_generic.c#2 integrate .. //depot/projects/uart/netinet/ip_dummynet.c#3 integrate .. //depot/projects/uart/security/mac_biba/mac_biba.c#2 integrate .. //depot/projects/uart/security/mac_mls/mac_mls.c#2 integrate .. //depot/projects/uart/sys/lock.h#2 integrate .. //depot/projects/uart/vm/swap_pager.c#5 integrate .. //depot/projects/uart/vm/swap_pager.h#3 integrate Differences ... ==== //depot/projects/uart/conf/files.alpha#4 (text+ko) ==== @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $FreeBSD: src/sys/conf/files.alpha,v 1.103 2003/07/22 11:41:15 ticso Exp $ +# $FreeBSD: src/sys/conf/files.alpha,v 1.104 2003/08/01 02:25:32 ambrisko Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -197,7 +197,7 @@ isa/atkbd_isa.c optional atkbd isa/atkbdc_isa.c optional atkbdc isa/fd.c optional fdc -isa/ppc.c optional ppc +dev/ppc/ppc.c optional ppc isa/psm.c optional psm isa/syscons_isa.c optional sc isa/vga_isa.c optional vga ==== //depot/projects/uart/conf/files.amd64#2 (text+ko) ==== @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $FreeBSD: src/sys/conf/files.amd64,v 1.18 2003/05/31 06:49:53 peter Exp $ +# $FreeBSD: src/sys/conf/files.amd64,v 1.19 2003/08/01 02:25:32 ambrisko Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -130,7 +130,7 @@ isa/atkbd_isa.c optional atkbd isa/atkbdc_isa.c optional atkbdc isa/fd.c optional fdc -isa/ppc.c optional ppc +dev/ppc/ppc.c optional ppc isa/psm.c optional psm isa/syscons_isa.c optional sc isa/vga_isa.c optional vga ==== //depot/projects/uart/conf/files.i386#4 (text+ko) ==== @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $FreeBSD: src/sys/conf/files.i386,v 1.448 2003/07/22 11:41:15 ticso Exp $ +# $FreeBSD: src/sys/conf/files.i386,v 1.449 2003/08/01 02:25:32 ambrisko Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -375,7 +375,8 @@ isa/atkbd_isa.c optional atkbd isa/atkbdc_isa.c optional atkbdc isa/fd.c optional fdc -isa/ppc.c optional ppc +dev/ppc/ppc.c optional ppc +dev/ppc/ppc_puc.c optional ppc puc pci isa/psm.c optional psm isa/syscons_isa.c optional sc isa/vga_isa.c optional vga ==== //depot/projects/uart/conf/files.ia64#4 (text+ko) ==== @@ -1,7 +1,7 @@ # This file tells config what files go into building a kernel, # files marked standard are always included. # -# $FreeBSD: src/sys/conf/files.ia64,v 1.53 2003/07/02 12:57:06 ru Exp $ +# $FreeBSD: src/sys/conf/files.ia64,v 1.54 2003/08/01 02:25:32 ambrisko Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -115,7 +115,7 @@ isa/atkbd_isa.c optional atkbd isa/atkbdc_isa.c optional atkbdc isa/fd.c optional fdc -isa/ppc.c optional ppc +dev/ppc/ppc.c optional ppc isa/psm.c optional psm isa/syscons_isa.c optional sc isa/vga_isa.c optional vga ==== //depot/projects/uart/ddb/db_command.c#2 (text+ko) ==== @@ -32,7 +32,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/ddb/db_command.c,v 1.50 2003/06/10 22:09:23 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/ddb/db_command.c,v 1.51 2003/07/31 17:27:52 jhb Exp $"); #include #include @@ -344,6 +344,7 @@ * Execute the command. */ (*cmd->fcn)(addr, have_addr, count, modif); + db_setup_paging(NULL, NULL, -1); if (cmd->flag & CS_SET_DOT) { /* ==== //depot/projects/uart/ddb/db_output.c#2 (text+ko) ==== @@ -33,7 +33,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/ddb/db_output.c,v 1.28 2003/06/10 22:09:23 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/ddb/db_output.c,v 1.29 2003/07/31 17:27:52 jhb Exp $"); #include #include @@ -62,6 +62,10 @@ #define NEXT_TAB(i) \ ((((i) + db_tab_stop_width) / db_tab_stop_width) * db_tab_stop_width) db_expr_t db_max_width = 79; /* output line width */ +static int db_newlines; /* # lines this page */ +static int db_maxlines = -1; /* max lines per page */ +static db_page_calloutfcn_t *db_page_callout = NULL; +static void *db_page_callout_arg = NULL; static void db_putchar(int c, void *arg); @@ -98,6 +102,7 @@ int c; /* character to output */ void * arg; { + if (c > ' ' && c <= '~') { /* * Printing character. @@ -115,6 +120,13 @@ db_output_position = 0; db_last_non_space = 0; db_check_interrupt(); + if (db_maxlines > 0 && db_page_callout != NULL) { + db_newlines++; + if (db_newlines >= db_maxlines) { + db_maxlines = -1; + db_page_callout(db_page_callout_arg); + } + } } else if (c == '\r') { /* Return */ @@ -139,6 +151,60 @@ } /* + * Register callout for providing a pager for output. + */ +void +db_setup_paging(db_page_calloutfcn_t *callout, void *arg, int maxlines) +{ + + db_page_callout = callout; + db_page_callout_arg = arg; + db_maxlines = maxlines; + db_newlines = 0; +} + +/* + * A simple paging callout function. If the argument is not null, it + * points to an integer that will be set to 1 if the user asks to quit. + */ +void +db_simple_pager(void *arg) +{ + int c; + + db_printf("--More--\r"); + for (;;) { + c = cngetc(); + switch (c) { + case '\n': + /* Just one more line. */ + db_setup_paging(db_simple_pager, arg, 1); + return; + case ' ': + /* Another page. */ + db_setup_paging(db_simple_pager, arg, + DB_LINES_PER_PAGE); + return; + case 'q': + case 'Q': + case 'x': + case 'X': + /* Quit */ + if (arg != NULL) { + *(int *)arg = 1; + db_printf("\n"); + return; + } +#if 0 + /* FALLTHROUGH */ + default: + cnputc('\007'); +#endif + } + } +} + +/* * Return output position */ int ==== //depot/projects/uart/ddb/db_ps.c#3 (text+ko) ==== @@ -32,7 +32,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/ddb/db_ps.c,v 1.47 2003/07/30 20:59:36 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/ddb/db_ps.c,v 1.48 2003/07/31 17:29:42 jhb Exp $"); #include #include @@ -55,13 +55,13 @@ db_expr_t dummy3; char * dummy4; { - int np; - int nl = 0; volatile struct proc *p, *pp; volatile struct thread *td; char *state; + int np, quit; np = nprocs; + quit = 0; /* sx_slock(&allproc_lock); */ if (!LIST_EMPTY(&allproc)) @@ -69,32 +69,9 @@ else p = &proc0; + db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); db_printf(" pid proc addr uid ppid pgrp flag stat wmesg wchan cmd\n"); - while (--np >= 0) { - /* - * XXX just take 20 for now... - */ - if (nl++ >= 20) { - int c; - - db_printf("--More--"); - c = cngetc(); - db_printf("\r"); - /* - * A whole screenfull or just one line? - */ - switch (c) { - case '\n': /* just one line */ - nl = 20; - break; - case ' ': - nl = 0; /* another screenfull */ - break; - default: /* exit */ - db_printf("\n"); - return; - } - } + while (--np >= 0 && !quit) { if (p == NULL) { printf("oops, ran out of processes early!\n"); break; @@ -131,7 +108,8 @@ db_printf("(threaded) %s\n", p->p_comm); FOREACH_THREAD_IN_PROC(p, td) { dumpthread(p, td); - nl++; + if (quit) + break; } /* PROC_UNLOCK(p); */ ==== //depot/projects/uart/ddb/ddb.h#2 (text+ko) ==== @@ -27,7 +27,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/ddb/ddb.h,v 1.33 2003/02/16 19:22:21 phk Exp $ + * $FreeBSD: src/sys/ddb/ddb.h,v 1.34 2003/07/31 17:27:52 jhb Exp $ */ /* @@ -39,9 +39,13 @@ #include /* type definitions */ +#define DB_LINES_PER_PAGE 20 + typedef void db_cmdfcn_t(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *modif); +typedef void db_page_calloutfcn_t(void *arg); + #define DB_COMMAND(cmd_name, func_name) \ DB_SET(cmd_name, func_name, db_cmd_set, 0, NULL) #define DB_SHOW_COMMAND(cmd_name, func_name) \ @@ -100,6 +104,8 @@ int db_readline(char *lstart, int lsize); void db_restart_at_pc(boolean_t watchpt); void db_set_watchpoints(void); +void db_setup_paging(db_page_calloutfcn_t *callout, void *arg, + int maxlines); void db_skip_to_eol(void); boolean_t db_stop_at_pc(boolean_t *is_breakpoint); #define db_strcpy strcpy @@ -139,6 +145,8 @@ db_cmdfcn_t vm_page_print; #endif +db_page_calloutfcn_t db_simple_pager; + /* Scare the user with backtrace of curthread to console. */ void db_print_backtrace(void); ==== //depot/projects/uart/dev/amd/amd.c#3 (text+ko) ==== @@ -30,7 +30,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/dev/amd/amd.c,v 1.21 2003/07/01 15:51:53 scottl Exp $ + * $FreeBSD: src/sys/dev/amd/amd.c,v 1.22 2003/07/31 16:55:44 ru Exp $ */ /* @@ -2497,3 +2497,4 @@ static devclass_t amd_devclass; DRIVER_MODULE(amd, pci, amd_driver, amd_devclass, 0, 0); +MODULE_DEPEND(amd, cam, 1, 1, 1); ==== //depot/projects/uart/dev/firewire/firewire.h#2 (text+ko) ==== @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/firewire/firewire.h,v 1.12 2003/04/17 03:38:02 simokawa Exp $ + * $FreeBSD: src/sys/dev/firewire/firewire.h,v 1.13 2003/08/01 04:51:21 simokawa Exp $ * */ @@ -47,7 +47,7 @@ }; struct fw_isobufreq { - struct { + struct fw_bufspec { unsigned int nchunk; unsigned int npacket; unsigned int psize; @@ -395,7 +395,7 @@ #define UNIT2MIN(x) (((x) & 0xff) << 8) #define DEV2UNIT(x) ((dev2unit(x) & 0xff00) >> 8) -#define DEV2DMACH(x) (dev2unit(x) & 0xff) +#define DEV2SUB(x) (dev2unit(x) & 0xff) #define FWMEM_FLAG 0x10000 #define DEV_FWMEM(x) (dev2unit(x) & FWMEM_FLAG) ==== //depot/projects/uart/dev/firewire/firewirereg.h#2 (text+ko) ==== @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/firewire/firewirereg.h,v 1.27 2003/06/28 11:11:36 simokawa Exp $ + * $FreeBSD: src/sys/dev/firewire/firewirereg.h,v 1.28 2003/08/01 04:51:21 simokawa Exp $ * */ @@ -191,8 +191,8 @@ #define FWXFERQ_HANDLER (1 << 16) #define FWXFERQ_WAKEUP (1 << 17) - void (*start) __P((struct firewire_comm*)); + int dmach; STAILQ_HEAD(, fw_xfer) q; u_int queued; u_int maxq; ==== //depot/projects/uart/dev/firewire/fwdev.c#3 (text+ko) ==== @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/dev/firewire/fwdev.c,v 1.29 2003/07/12 09:34:44 simokawa Exp $ + * $FreeBSD: src/sys/dev/firewire/fwdev.c,v 1.30 2003/08/01 04:51:21 simokawa Exp $ * */ @@ -86,34 +86,99 @@ #endif }; +struct fw_drv1 { + struct fw_xferq *ir; + struct fw_xferq *it; + struct fw_isobufreq bufreq; +}; + +static int +fwdev_allocbuf(struct firewire_comm *fc, struct fw_xferq *q, + struct fw_bufspec *b) +{ + int i; + + if (q->flag & (FWXFERQ_RUNNING | FWXFERQ_EXTBUF)) + return(EBUSY); + + q->bulkxfer = (struct fw_bulkxfer *) malloc( + sizeof(struct fw_bulkxfer) * b->nchunk, + M_FW, M_WAITOK); + if (q->bulkxfer == NULL) + return(ENOMEM); + + b->psize = roundup2(b->psize, sizeof(u_int32_t)); + q->buf = fwdma_malloc_multiseg(fc, sizeof(u_int32_t), + b->psize, b->nchunk * b->npacket, BUS_DMA_WAITOK); + + if (q->buf == NULL) { + free(q->bulkxfer, M_FW); + q->bulkxfer = NULL; + return(ENOMEM); + } + q->bnchunk = b->nchunk; + q->bnpacket = b->npacket; + q->psize = (b->psize + 3) & ~3; + q->queued = 0; + + STAILQ_INIT(&q->stvalid); + STAILQ_INIT(&q->stfree); + STAILQ_INIT(&q->stdma); + q->stproc = NULL; + + for(i = 0 ; i < q->bnchunk; i++){ + q->bulkxfer[i].poffset = i * q->bnpacket; + q->bulkxfer[i].mbuf = NULL; + STAILQ_INSERT_TAIL(&q->stfree, &q->bulkxfer[i], link); + } + + q->flag &= ~FWXFERQ_MODEMASK; + q->flag |= FWXFERQ_STREAM; + q->flag |= FWXFERQ_EXTBUF; + + return (0); +} + static int +fwdev_freebuf(struct fw_xferq *q) +{ + if (q->flag & FWXFERQ_EXTBUF) { + if (q->buf != NULL) + fwdma_free_multiseg(q->buf); + q->buf = NULL; + free(q->bulkxfer, M_FW); + q->bulkxfer = NULL; + q->flag &= ~FWXFERQ_EXTBUF; + q->psize = 0; + q->maxq = FWMAXQUEUE; + } + return (0); +} + + +static int fw_open (dev_t dev, int flags, int fmt, fw_proc *td) { - struct firewire_softc *sc; int unit = DEV2UNIT(dev); - int sub = DEV2DMACH(dev); + int sub = DEV2SUB(dev); int err = 0; + if (dev->si_drv1 != NULL) + return (EBUSY); + if (DEV_FWMEM(dev)) return fwmem_open(dev, flags, fmt, td); - sc = devclass_get_softc(firewire_devclass, unit); - if(sc->fc->ir[sub]->flag & FWXFERQ_OPEN){ - err = EBUSY; - return err; - } - if(sc->fc->it[sub]->flag & FWXFERQ_OPEN){ - err = EBUSY; - return err; - } - if(sc->fc->ir[sub]->flag & FWXFERQ_MODEMASK){ - err = EBUSY; - return err; - } -/* Default is per packet mode */ - sc->fc->ir[sub]->flag |= FWXFERQ_OPEN; - sc->fc->it[sub]->flag |= FWXFERQ_OPEN; +#if __FreeBSD_version >= 500000 + if ((dev->si_flags & SI_NAMED) == 0) +#endif + make_dev(&firewire_cdevsw, minor(dev), + UID_ROOT, GID_OPERATOR, 0660, + "fw%d.%d", unit, sub); + + dev->si_drv1 = malloc(sizeof(struct fw_drv1), M_FW, M_WAITOK | M_ZERO); + return err; } @@ -121,8 +186,9 @@ fw_close (dev_t dev, int flags, int fmt, fw_proc *td) { struct firewire_softc *sc; + struct firewire_comm *fc; + struct fw_drv1 *d; int unit = DEV2UNIT(dev); - int sub = DEV2DMACH(dev); struct fw_xfer *xfer; struct fw_bind *fwb; int err = 0; @@ -131,60 +197,59 @@ return fwmem_close(dev, flags, fmt, td); sc = devclass_get_softc(firewire_devclass, unit); - if(!(sc->fc->ir[sub]->flag & FWXFERQ_OPEN)){ - err = EINVAL; - return err; + fc = sc->fc; + d = (struct fw_drv1 *)dev->si_drv1; + + if (d->ir != NULL) { + struct fw_xferq *ir = d->ir; + + if ((ir->flag & FWXFERQ_OPEN) == 0) + return (EINVAL); + if (ir->flag & FWXFERQ_RUNNING) { + ir->flag &= ~FWXFERQ_RUNNING; + fc->irx_disable(fc, ir->dmach); + } + /* free extbuf */ + fwdev_freebuf(ir); + /* drain receiving buffer */ + for (xfer = STAILQ_FIRST(&ir->q); + xfer != NULL; xfer = STAILQ_FIRST(&ir->q)) { + ir->queued --; + STAILQ_REMOVE_HEAD(&ir->q, link); + + xfer->resp = 0; + fw_xfer_done(xfer); + } + /* remove binding */ + for (fwb = STAILQ_FIRST(&ir->binds); fwb != NULL; + fwb = STAILQ_FIRST(&ir->binds)) { + STAILQ_REMOVE(&fc->binds, fwb, fw_bind, fclist); + STAILQ_REMOVE_HEAD(&ir->binds, chlist); + free(fwb, M_FW); + } + ir->flag &= ~(FWXFERQ_OPEN | + FWXFERQ_MODEMASK | FWXFERQ_CHTAGMASK); + d->ir = NULL; + } - sc->fc->ir[sub]->flag &= ~FWXFERQ_OPEN; - if(!(sc->fc->it[sub]->flag & FWXFERQ_OPEN)){ - err = EINVAL; - return err; - } - sc->fc->it[sub]->flag &= ~FWXFERQ_OPEN; + if (d->it != NULL) { + struct fw_xferq *it = d->it; - if(sc->fc->ir[sub]->flag & FWXFERQ_RUNNING){ - sc->fc->irx_disable(sc->fc, sub); + if ((it->flag & FWXFERQ_OPEN) == 0) + return (EINVAL); + if (it->flag & FWXFERQ_RUNNING) { + it->flag &= ~FWXFERQ_RUNNING; + fc->itx_disable(fc, it->dmach); + } + /* free extbuf */ + fwdev_freebuf(it); + it->flag &= ~(FWXFERQ_OPEN | + FWXFERQ_MODEMASK | FWXFERQ_CHTAGMASK); + d->it = NULL; } - if(sc->fc->it[sub]->flag & FWXFERQ_RUNNING){ - sc->fc->it[sub]->flag &= ~FWXFERQ_RUNNING; - sc->fc->itx_disable(sc->fc, sub); - } - if(sc->fc->ir[sub]->flag & FWXFERQ_EXTBUF){ - if (sc->fc->ir[sub]->buf != NULL) - fwdma_free_multiseg(sc->fc->ir[sub]->buf); - sc->fc->ir[sub]->buf = NULL; - free(sc->fc->ir[sub]->bulkxfer, M_FW); - sc->fc->ir[sub]->bulkxfer = NULL; - sc->fc->ir[sub]->flag &= ~FWXFERQ_EXTBUF; - sc->fc->ir[sub]->psize = PAGE_SIZE; - sc->fc->ir[sub]->maxq = FWMAXQUEUE; - } - if(sc->fc->it[sub]->flag & FWXFERQ_EXTBUF){ - if (sc->fc->it[sub]->buf != NULL) - fwdma_free_multiseg(sc->fc->it[sub]->buf); - sc->fc->it[sub]->buf = NULL; - free(sc->fc->it[sub]->bulkxfer, M_FW); - sc->fc->it[sub]->bulkxfer = NULL; - sc->fc->it[sub]->flag &= ~FWXFERQ_EXTBUF; - sc->fc->it[sub]->psize = 0; - sc->fc->it[sub]->maxq = FWMAXQUEUE; - } - for(xfer = STAILQ_FIRST(&sc->fc->ir[sub]->q); - xfer != NULL; xfer = STAILQ_FIRST(&sc->fc->ir[sub]->q)){ - sc->fc->ir[sub]->queued--; - STAILQ_REMOVE_HEAD(&sc->fc->ir[sub]->q, link); + free(dev->si_drv1, M_FW); + dev->si_drv1 = NULL; - xfer->resp = 0; - fw_xfer_done(xfer); - } - for(fwb = STAILQ_FIRST(&sc->fc->ir[sub]->binds); fwb != NULL; - fwb = STAILQ_FIRST(&sc->fc->ir[sub]->binds)){ - STAILQ_REMOVE(&sc->fc->binds, fwb, fw_bind, fclist); - STAILQ_REMOVE_HEAD(&sc->fc->ir[sub]->binds, chlist); - free(fwb, M_FW); - } - sc->fc->ir[sub]->flag &= ~(FWXFERQ_MODEMASK | FWXFERQ_CHTAGMASK); - sc->fc->it[sub]->flag &= ~(FWXFERQ_MODEMASK | FWXFERQ_CHTAGMASK); return err; } @@ -199,7 +264,6 @@ struct fw_xfer *xfer; int err = 0, s, slept = 0; int unit = DEV2UNIT(dev); - int sub = DEV2DMACH(dev); struct fw_pkt *fp; if (DEV_FWMEM(dev)) @@ -207,7 +271,9 @@ sc = devclass_get_softc(firewire_devclass, unit); - ir = sc->fc->ir[sub]; + ir = ((struct fw_drv1 *)dev->si_drv1)->ir; + if (ir == NULL || ir->buf == NULL) + return (EIO); readloop: xfer = STAILQ_FIRST(&ir->q); @@ -262,7 +328,7 @@ s = splfw(); STAILQ_INSERT_TAIL(&ir->stfree, ir->stproc, link); splx(s); - sc->fc->irx_enable(sc->fc, sub); + sc->fc->irx_enable(sc->fc, ir->dmach); ir->stproc = NULL; } if (uio->uio_resid >= ir->psize) { @@ -279,7 +345,6 @@ int err = 0; struct firewire_softc *sc; int unit = DEV2UNIT(dev); - int sub = DEV2DMACH(dev); int s, slept = 0; struct fw_pkt *fp; struct firewire_comm *fc; @@ -290,7 +355,9 @@ sc = devclass_get_softc(firewire_devclass, unit); fc = sc->fc; - it = sc->fc->it[sub]; + it = ((struct fw_drv1 *)dev->si_drv1)->it; + if (it == NULL || it->buf == NULL) + return (EIO); isoloop: if (it->stproc == NULL) { it->stproc = STAILQ_FIRST(&it->stfree); @@ -301,7 +368,7 @@ it->queued = 0; } else if (slept == 0) { slept = 1; - err = sc->fc->itx_enable(sc->fc, sub); + err = sc->fc->itx_enable(sc->fc, it->dmach); if (err) return err; err = tsleep(it, FWPRI, "fw_write", hz); @@ -324,7 +391,7 @@ STAILQ_INSERT_TAIL(&it->stvalid, it->stproc, link); splx(s); it->stproc = NULL; - err = sc->fc->itx_enable(sc->fc, sub); + err = sc->fc->itx_enable(sc->fc, it->dmach); } if (uio->uio_resid >= sizeof(struct fw_isohdr)) { slept = 0; @@ -332,7 +399,6 @@ } return err; } - /* * ioctl support. */ @@ -340,8 +406,9 @@ fw_ioctl (dev_t dev, u_long cmd, caddr_t data, int flag, fw_proc *td) { struct firewire_softc *sc; + struct firewire_comm *fc; + struct fw_drv1 *d; int unit = DEV2UNIT(dev); - int sub = DEV2DMACH(dev); int s, i, len, err = 0; struct fw_device *fwdev; struct fw_bind *fwb; @@ -361,146 +428,93 @@ if (DEV_FWMEM(dev)) return fwmem_ioctl(dev, cmd, data, flag, td); - sc = devclass_get_softc(firewire_devclass, unit); if (!data) return(EINVAL); + sc = devclass_get_softc(firewire_devclass, unit); + fc = sc->fc; + d = (struct fw_drv1 *)dev->si_drv1; + ir = d->ir; + it = d->it; + switch (cmd) { case FW_STSTREAM: - sc->fc->it[sub]->flag &= ~0xff; - sc->fc->it[sub]->flag |= (0x3f & ichreq->ch); - sc->fc->it[sub]->flag |= ((0x3 & ichreq->tag) << 6); + if (it == NULL) { + for (i = 0; i < fc->nisodma; i ++) { + it = fc->it[i]; + if ((it->flag & FWXFERQ_OPEN) == 0) + break; + } + if (i >= fc->nisodma) { + err = EBUSY; + break; + } + err = fwdev_allocbuf(fc, it, &d->bufreq.tx); + if (err) + break; + it->flag |= FWXFERQ_OPEN; + } + it->flag &= ~0xff; + it->flag |= (0x3f & ichreq->ch); + it->flag |= ((0x3 & ichreq->tag) << 6); + d->it = it; err = 0; break; case FW_GTSTREAM: - ichreq->ch = sc->fc->it[sub]->flag & 0x3f; - ichreq->tag =(sc->fc->it[sub]->flag) >> 2 & 0x3; - err = 0; + if (it != NULL) { + ichreq->ch = it->flag & 0x3f; + ichreq->tag = it->flag >> 2 & 0x3; + err = 0; + } else + err = EINVAL; break; case FW_SRSTREAM: - sc->fc->ir[sub]->flag &= ~0xff; - sc->fc->ir[sub]->flag |= (0x3f & ichreq->ch); - sc->fc->ir[sub]->flag |= ((0x3 & ichreq->tag) << 6); - err = sc->fc->irx_enable(sc->fc, sub); + if (ir == NULL) { + for (i = 0; i < fc->nisodma; i ++) { + ir = fc->ir[i]; + if ((ir->flag & FWXFERQ_OPEN) == 0) + break; + } + if (i >= fc->nisodma) { + err = EBUSY; + break; + } + err = fwdev_allocbuf(fc, ir, &d->bufreq.rx); + if (err) + break; + ir->flag |= FWXFERQ_OPEN; + } + ir->flag &= ~0xff; + ir->flag |= (0x3f & ichreq->ch); + ir->flag |= ((0x3 & ichreq->tag) << 6); + d->ir = ir; + err = fc->irx_enable(fc, ir->dmach); break; case FW_GRSTREAM: - ichreq->ch = sc->fc->ir[sub]->flag & 0x3f; - ichreq->tag =(sc->fc->ir[sub]->flag) >> 2 & 0x3; - err = 0; + if (d->ir != NULL) { + ichreq->ch = ir->flag & 0x3f; + ichreq->tag = ir->flag >> 2 & 0x3; + err = 0; + } else + err = EINVAL; break; case FW_SSTBUF: - ir = sc->fc->ir[sub]; - it = sc->fc->it[sub]; - - if(ir->flag & FWXFERQ_RUNNING || it->flag & FWXFERQ_RUNNING){ - return(EBUSY); - } - if((ir->flag & FWXFERQ_EXTBUF) || (it->flag & FWXFERQ_EXTBUF)){ - return(EBUSY); - } - if((ibufreq->rx.nchunk * - ibufreq->rx.psize * ibufreq->rx.npacket) + - (ibufreq->tx.nchunk * - ibufreq->tx.psize * ibufreq->tx.npacket) <= 0){ - return(EINVAL); - } - ir->bulkxfer - = (struct fw_bulkxfer *)malloc(sizeof(struct fw_bulkxfer) * ibufreq->rx.nchunk, M_FW, M_WAITOK); - if(ir->bulkxfer == NULL){ - return(ENOMEM); - } - it->bulkxfer - = (struct fw_bulkxfer *)malloc(sizeof(struct fw_bulkxfer) * ibufreq->tx.nchunk, M_FW, M_WAITOK); - if(it->bulkxfer == NULL){ - return(ENOMEM); - } - if (ibufreq->rx.psize > 0) { - ibufreq->rx.psize = roundup2(ibufreq->rx.psize, - sizeof(u_int32_t)); - ir->buf = fwdma_malloc_multiseg( - sc->fc, sizeof(u_int32_t), - ibufreq->rx.psize, - ibufreq->rx.nchunk * ibufreq->rx.npacket, - BUS_DMA_WAITOK); - - if(ir->buf == NULL){ - free(ir->bulkxfer, M_FW); - free(it->bulkxfer, M_FW); - ir->bulkxfer = NULL; - it->bulkxfer = NULL; - it->buf = NULL; - return(ENOMEM); - } - } - if (ibufreq->tx.psize > 0) { - ibufreq->tx.psize = roundup2(ibufreq->tx.psize, - sizeof(u_int32_t)); - it->buf = fwdma_malloc_multiseg( - sc->fc, sizeof(u_int32_t), - ibufreq->tx.psize, - ibufreq->tx.nchunk * ibufreq->tx.npacket, - BUS_DMA_WAITOK); - - if(it->buf == NULL){ - free(ir->bulkxfer, M_FW); - free(it->bulkxfer, M_FW); - fwdma_free_multiseg(ir->buf); - ir->bulkxfer = NULL; - it->bulkxfer = NULL; - it->buf = NULL; - return(ENOMEM); - } - } - - ir->bnchunk = ibufreq->rx.nchunk; - ir->bnpacket = ibufreq->rx.npacket; - ir->psize = (ibufreq->rx.psize + 3) & ~3; - ir->queued = 0; - - it->bnchunk = ibufreq->tx.nchunk; - it->bnpacket = ibufreq->tx.npacket; - it->psize = (ibufreq->tx.psize + 3) & ~3; - it->queued = 0; - - STAILQ_INIT(&ir->stvalid); - STAILQ_INIT(&ir->stfree); - STAILQ_INIT(&ir->stdma); - ir->stproc = NULL; - - STAILQ_INIT(&it->stvalid); - STAILQ_INIT(&it->stfree); - STAILQ_INIT(&it->stdma); - it->stproc = NULL; - - for(i = 0 ; i < sc->fc->ir[sub]->bnchunk; i++){ - ir->bulkxfer[i].poffset = i * ir->bnpacket; - ir->bulkxfer[i].mbuf = NULL; - STAILQ_INSERT_TAIL(&ir->stfree, - &ir->bulkxfer[i], link); - } - for(i = 0 ; i < sc->fc->it[sub]->bnchunk; i++){ - it->bulkxfer[i].poffset = i * it->bnpacket; - it->bulkxfer[i].mbuf = NULL; - STAILQ_INSERT_TAIL(&it->stfree, - &it->bulkxfer[i], link); - } - ir->flag &= ~FWXFERQ_MODEMASK; - ir->flag |= FWXFERQ_STREAM; - ir->flag |= FWXFERQ_EXTBUF; - - it->flag &= ~FWXFERQ_MODEMASK; - it->flag |= FWXFERQ_STREAM; - it->flag |= FWXFERQ_EXTBUF; + bcopy(ibufreq, &d->bufreq, sizeof(d->bufreq)); err = 0; break; case FW_GSTBUF: - ibufreq->rx.nchunk = sc->fc->ir[sub]->bnchunk; - ibufreq->rx.npacket = sc->fc->ir[sub]->bnpacket; - ibufreq->rx.psize = sc->fc->ir[sub]->psize; - - ibufreq->tx.nchunk = sc->fc->it[sub]->bnchunk; - ibufreq->tx.npacket = sc->fc->it[sub]->bnpacket; - ibufreq->tx.psize = sc->fc->it[sub]->psize; + bzero(&ibufreq->rx, sizeof(ibufreq->rx)); + if (ir != NULL) { + ibufreq->rx.nchunk = ir->bnchunk; + ibufreq->rx.npacket = ir->bnpacket; + ibufreq->rx.psize = ir->psize; + } + bzero(&ibufreq->tx, sizeof(ibufreq->tx)); + if (it != NULL) { + ibufreq->tx.nchunk = it->bnchunk; + ibufreq->tx.npacket = it->bnpacket; + ibufreq->tx.psize = it->psize; + } break; case FW_ASYREQ: xfer = fw_xfer_alloc_buf(M_FWXFER, asyreq->req.len, >>> TRUNCATED FOR MAIL (1000 lines) <<<