From owner-p4-projects@FreeBSD.ORG Tue Oct 5 20:45:02 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 70F8716A4D0; Tue, 5 Oct 2004 20:45:02 +0000 (GMT) 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 33F6816A4CE for ; Tue, 5 Oct 2004 20:45:02 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 07EC843D39 for ; Tue, 5 Oct 2004 20:45:02 +0000 (GMT) (envelope-from julian@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i95Kj21v072590 for ; Tue, 5 Oct 2004 20:45:02 GMT (envelope-from julian@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i95Kj1wa072587 for perforce@freebsd.org; Tue, 5 Oct 2004 20:45:01 GMT (envelope-from julian@freebsd.org) Date: Tue, 5 Oct 2004 20:45:01 GMT Message-Id: <200410052045.i95Kj1wa072587@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to julian@freebsd.org using -f From: Julian Elischer To: Perforce Change Reviews Subject: PERFORCE change 62690 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: Tue, 05 Oct 2004 20:45:02 -0000 http://perforce.freebsd.org/chv.cgi?CH=62690 Change 62690 by julian@julian_ref on 2004/10/05 20:44:50 IFC@62689 Affected files ... .. //depot/projects/nsched/sys/alpha/osf1/osf1_misc.c#4 integrate .. //depot/projects/nsched/sys/amd64/linux32/linux32_machdep.c#4 integrate .. //depot/projects/nsched/sys/boot/common/help.common#5 integrate .. //depot/projects/nsched/sys/boot/forth/loader.conf#9 integrate .. //depot/projects/nsched/sys/cam/cam_periph.h#3 integrate .. //depot/projects/nsched/sys/cam/cam_xpt.c#5 integrate .. //depot/projects/nsched/sys/compat/freebsd32/freebsd32_misc.c#4 integrate .. //depot/projects/nsched/sys/compat/linux/linux_misc.c#4 integrate .. //depot/projects/nsched/sys/compat/svr4/svr4_misc.c#3 integrate .. //depot/projects/nsched/sys/conf/NOTES#22 integrate .. //depot/projects/nsched/sys/dev/cy/cy.c#10 integrate .. //depot/projects/nsched/sys/dev/fdc/fdc_isa.c#6 integrate .. //depot/projects/nsched/sys/dev/rp/rp.c#9 integrate .. //depot/projects/nsched/sys/dev/rp/rpvar.h#3 integrate .. //depot/projects/nsched/sys/dev/usb/umct.c#5 integrate .. //depot/projects/nsched/sys/fs/procfs/procfs_status.c#3 integrate .. //depot/projects/nsched/sys/fs/unionfs/union.h#3 integrate .. //depot/projects/nsched/sys/fs/unionfs/union_vfsops.c#5 integrate .. //depot/projects/nsched/sys/fs/unionfs/union_vnops.c#5 integrate .. //depot/projects/nsched/sys/geom/mirror/g_mirror.c#10 integrate .. //depot/projects/nsched/sys/kern/init_main.c#14 integrate .. //depot/projects/nsched/sys/kern/kern_acct.c#3 integrate .. //depot/projects/nsched/sys/kern/kern_clock.c#8 integrate .. //depot/projects/nsched/sys/kern/kern_descrip.c#9 integrate .. //depot/projects/nsched/sys/kern/kern_exit.c#20 integrate .. //depot/projects/nsched/sys/kern/kern_kse.c#32 integrate .. //depot/projects/nsched/sys/kern/kern_proc.c#14 integrate .. //depot/projects/nsched/sys/kern/kern_resource.c#9 integrate .. //depot/projects/nsched/sys/kern/kern_shutdown.c#10 integrate .. //depot/projects/nsched/sys/kern/kern_sig.c#13 integrate .. //depot/projects/nsched/sys/kern/kern_synch.c#17 integrate .. //depot/projects/nsched/sys/kern/kern_thread.c#42 integrate .. //depot/projects/nsched/sys/kern/kern_time.c#5 integrate .. //depot/projects/nsched/sys/kern/subr_taskqueue.c#4 integrate .. //depot/projects/nsched/sys/kern/subr_trap.c#7 integrate .. //depot/projects/nsched/sys/kern/subr_turnstile.c#6 integrate .. //depot/projects/nsched/sys/kern/tty.c#12 integrate .. //depot/projects/nsched/sys/kern/vfs_mount.c#10 integrate .. //depot/projects/nsched/sys/net/ethernet.h#3 integrate .. //depot/projects/nsched/sys/net/route.h#5 integrate .. //depot/projects/nsched/sys/net/rtsock.c#9 integrate .. //depot/projects/nsched/sys/netinet/tcp_input.c#10 integrate .. //depot/projects/nsched/sys/netinet/tcp_output.c#8 integrate .. //depot/projects/nsched/sys/netinet/tcp_sack.c#3 integrate .. //depot/projects/nsched/sys/netinet/tcp_subr.c#9 integrate .. //depot/projects/nsched/sys/netinet/tcp_var.h#7 integrate .. //depot/projects/nsched/sys/pci/agp_amd64.c#2 integrate .. //depot/projects/nsched/sys/sys/_task.h#3 integrate .. //depot/projects/nsched/sys/sys/interrupt.h#3 integrate .. //depot/projects/nsched/sys/sys/proc.h#37 integrate .. //depot/projects/nsched/sys/sys/resourcevar.h#6 integrate .. //depot/projects/nsched/sys/sys/syscallsubr.h#4 integrate .. //depot/projects/nsched/sys/sys/taskqueue.h#3 integrate .. //depot/projects/nsched/sys/ufs/ffs/ffs_vfsops.c#10 integrate Differences ... ==== //depot/projects/nsched/sys/alpha/osf1/osf1_misc.c#4 (text+ko) ==== @@ -30,7 +30,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/alpha/osf1/osf1_misc.c,v 1.48 2004/08/24 20:21:21 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/alpha/osf1/osf1_misc.c,v 1.49 2004/10/05 18:51:09 jhb Exp $"); #include #include @@ -1335,29 +1335,16 @@ struct thread *td; struct osf1_getrusage_args *uap; { - struct proc *p; - struct rusage *rup; struct osf1_rusage oru; + struct rusage ru; + int error; - p = td->td_proc; - switch (uap->who) { - case RUSAGE_SELF: - rup = &p->p_stats->p_ru; - mtx_lock_spin(&sched_lock); - calcru(p, &rup->ru_utime, &rup->ru_stime, NULL); - mtx_unlock_spin(&sched_lock); - break; - - case RUSAGE_CHILDREN: - rup = &p->p_stats->p_cru; - break; - - default: - return (EINVAL); - } - TV_CP(rup->ru_utime, oru.ru_utime); - TV_CP(rup->ru_stime, oru.ru_stime); - bcopy(&(rup->ru_first), &(oru.ru_first), + error = kern_getrusage(td, uap->who, &ru); + if (error) + return (error); + TV_CP(ru.ru_utime, oru.ru_utime); + TV_CP(ru.ru_stime, oru.ru_stime); + bcopy(&(ru.ru_first), &(oru.ru_first), (&(oru.ru_last) - &(oru.ru_first))); return (copyout((caddr_t)&oru, (caddr_t)uap->rusage, @@ -1372,9 +1359,13 @@ { int error, status; struct osf1_rusage oru; - struct rusage ru; + struct rusage ru, *rup; - error = kern_wait(td, uap->pid, &status, uap->options, &ru); + if (uap->rusage != NULL) + rup = &ru; + else + rup = NULL; + error = kern_wait(td, uap->pid, &status, uap->options, rup); if (error) return (error); if (uap->status != NULL) ==== //depot/projects/nsched/sys/amd64/linux32/linux32_machdep.c#4 (text+ko) ==== @@ -29,7 +29,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/amd64/linux32/linux32_machdep.c,v 1.4 2004/09/01 02:11:27 julian Exp $"); +__FBSDID("$FreeBSD: src/sys/amd64/linux32/linux32_machdep.c,v 1.5 2004/10/05 18:51:10 jhb Exp $"); #include #include @@ -940,24 +940,14 @@ int linux_getrusage(struct thread *td, struct linux_getrusage_args *uap) { + struct l_rusage s32; + struct rusage s; int error; - caddr_t sg; - struct l_rusage *p32, s32; - struct rusage *p = NULL, s; - p32 = uap->rusage; - if (p32 != NULL) { - sg = stackgap_init(); - p = stackgap_alloc(&sg, sizeof(struct rusage)); - uap->rusage = (struct l_rusage *)p; - } - error = getrusage(td, (struct getrusage_args *) uap); + error = kern_getrusage(td, uap->who, &s); if (error != 0) return (error); - if (p32 != NULL) { - error = copyin(p, &s, sizeof(s)); - if (error != 0) - return (error); + if (uap->rusage != NULL) { s32.ru_utime.tv_sec = s.ru_utime.tv_sec; s32.ru_utime.tv_usec = s.ru_utime.tv_usec; s32.ru_stime.tv_sec = s.ru_stime.tv_sec; @@ -976,7 +966,7 @@ s32.ru_nsignals = s.ru_nsignals; s32.ru_nvcsw = s.ru_nvcsw; s32.ru_nivcsw = s.ru_nivcsw; - error = copyout(&s32, p32, sizeof(s32)); + error = copyout(&s32, uap->rusage, sizeof(s32)); } return (error); } ==== //depot/projects/nsched/sys/boot/common/help.common#5 (text+ko) ==== @@ -319,13 +319,6 @@ value is 1 (default), but this may cause problems with some peripherals. Set to 0 to disable. - set vfs.root.mountdelay= - - Delay root partition mount if there is no required provider. - - value is a maximum number of seconds to wait for provider to - show up (default is 5 seconds). - ################################################################################ # Tshow DShow the values of variables ==== //depot/projects/nsched/sys/boot/forth/loader.conf#9 (text+ko) ==== @@ -6,7 +6,7 @@ # # All arguments must be in double quotes. # -# $FreeBSD: src/sys/boot/forth/loader.conf,v 1.90 2004/09/30 20:02:07 ru Exp $ +# $FreeBSD: src/sys/boot/forth/loader.conf,v 1.91 2004/10/05 11:26:43 pjd Exp $ ############################################################## ### Basic configuration options ############################ @@ -98,8 +98,6 @@ #net.inet.tcp.tcbhashsize="" # Set the value of TCBHASHSIZE #vfs.root.mountfrom="" # Specify root partition in a way the # kernel understands -#vfs.root.mountdelay="5" # Delay root partition mount if there is no - # required provider #vm.kmem_size="" # Sets the size of kernel memory (bytes) #debug.ktr.cpumask="0xf" # Bitmask of CPUs to enable KTR on #debug.ktr.mask="0x1200" # Bitmask of KTR events to enable ==== //depot/projects/nsched/sys/cam/cam_periph.h#3 (text+ko) ==== @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cam/cam_periph.h,v 1.14 2004/07/15 08:25:59 phk Exp $ + * $FreeBSD: src/sys/cam/cam_periph.h,v 1.15 2004/10/05 04:22:20 scottl Exp $ */ #ifndef _CAM_CAM_PERIPH_H @@ -81,8 +81,7 @@ }; typedef enum { - CAM_PERIPH_BIO, - CAM_PERIPH_NET + CAM_PERIPH_BIO } cam_periph_type; /* Generically usefull offsets into the peripheral private area */ ==== //depot/projects/nsched/sys/cam/cam_xpt.c#5 (text+ko) ==== @@ -28,7 +28,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/cam/cam_xpt.c,v 1.142 2004/07/15 08:25:59 phk Exp $"); +__FBSDID("$FreeBSD: src/sys/cam/cam_xpt.c,v 1.143 2004/10/05 04:22:20 scottl Exp $"); #include #include @@ -598,7 +598,6 @@ /* Queues for our software interrupt handler */ typedef TAILQ_HEAD(cam_isrq, ccb_hdr) cam_isrq_t; static cam_isrq_t cam_bioq; -static cam_isrq_t cam_netq; /* "Pool" of inactive ccbs managed by xpt_alloc_ccb and xpt_free_ccb */ static SLIST_HEAD(,ccb_hdr) ccb_freeq; @@ -658,7 +657,6 @@ #endif /* Pointers to software interrupt handlers */ -static void *camnet_ih; static void *cambio_ih; #if defined(CAM_DEBUG_FLAGS) && !defined(CAMDEBUG) @@ -1367,7 +1365,6 @@ TAILQ_INIT(&xpt_busses); TAILQ_INIT(&cam_bioq); - TAILQ_INIT(&cam_netq); SLIST_INIT(&ccb_freeq); STAILQ_INIT(&highpowerq); @@ -1429,7 +1426,6 @@ } /* Install our software interrupt handlers */ - swi_add(NULL, "camnet", camisr, &cam_netq, SWI_CAMNET, 0, &camnet_ih); swi_add(NULL, "cambio", camisr, &cam_bioq, SWI_CAMBIO, 0, &cambio_ih); } @@ -3610,7 +3606,6 @@ && (--timeout > 0)) { DELAY(1000); (*(sim->sim_poll))(sim); - camisr(&cam_netq); camisr(&cam_bioq); } @@ -3621,7 +3616,6 @@ xpt_action(start_ccb); while(--timeout > 0) { (*(sim->sim_poll))(sim); - camisr(&cam_netq); camisr(&cam_bioq); if ((start_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_INPROG) @@ -4838,12 +4832,9 @@ done_ccb->ccb_h.pinfo.index = CAM_DONEQ_INDEX; swi_sched(cambio_ih, 0); break; - case CAM_PERIPH_NET: - TAILQ_INSERT_TAIL(&cam_netq, &done_ccb->ccb_h, - sim_links.tqe); - done_ccb->ccb_h.pinfo.index = CAM_DONEQ_INDEX; - swi_sched(camnet_ih, 0); - break; + default: + panic("unknown periph type %d", + done_ccb->ccb_h.path->periph->type); } } splx(s); ==== //depot/projects/nsched/sys/compat/freebsd32/freebsd32_misc.c#4 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/compat/freebsd32/freebsd32_misc.c,v 1.23 2004/06/17 17:16:41 phk Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/freebsd32/freebsd32_misc.c,v 1.24 2004/10/05 18:51:10 jhb Exp $"); #include "opt_compat.h" @@ -91,9 +91,13 @@ { int error, status; struct rusage32 ru32; - struct rusage ru; + struct rusage ru, *rup; - error = kern_wait(td, uap->pid, &status, uap->options, &ru); + if (uap->rusage != NULL) + rup = &ru; + else + rup = NULL; + error = kern_wait(td, uap->pid, &status, uap->options, rup); if (error) return (error); if (uap->status != NULL) @@ -639,24 +643,14 @@ int freebsd32_getrusage(struct thread *td, struct freebsd32_getrusage_args *uap) { + struct rusage32 s32; + struct rusage s; int error; - caddr_t sg; - struct rusage32 *p32, s32; - struct rusage *p = NULL, s; - p32 = uap->rusage; - if (p32) { - sg = stackgap_init(); - p = stackgap_alloc(&sg, sizeof(struct rusage)); - uap->rusage = (struct rusage32 *)p; - } - error = getrusage(td, (struct getrusage_args *) uap); + error = kern_getrusage(td, uap->who, &s); if (error) return (error); - if (p32) { - error = copyin(p, &s, sizeof(s)); - if (error) - return (error); + if (uap->rusage != NULL) { TV_CP(s, s32, ru_utime); TV_CP(s, s32, ru_stime); CP(s, s32, ru_maxrss); @@ -673,7 +667,7 @@ CP(s, s32, ru_nsignals); CP(s, s32, ru_nvcsw); CP(s, s32, ru_nivcsw); - error = copyout(&s32, p32, sizeof(s32)); + error = copyout(&s32, uap->rusage, sizeof(s32)); } return (error); } ==== //depot/projects/nsched/sys/compat/linux/linux_misc.c#4 (text+ko) ==== @@ -28,7 +28,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/compat/linux/linux_misc.c,v 1.160 2004/08/16 11:12:57 obrien Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/linux/linux_misc.c,v 1.161 2004/10/05 18:51:10 jhb Exp $"); #include "opt_mac.h" @@ -689,9 +689,9 @@ int linux_times(struct thread *td, struct linux_times_args *args) { - struct timeval tv; + struct timeval tv, utime, stime, cutime, cstime; struct l_times_argv tms; - struct rusage ru; + struct proc *p; int error; #ifdef DEBUG @@ -699,15 +699,17 @@ printf(ARGS(times, "*")); #endif - mtx_lock_spin(&sched_lock); - calcru(td->td_proc, &ru.ru_utime, &ru.ru_stime, NULL); - mtx_unlock_spin(&sched_lock); + p = td->td_proc; + PROC_LOCK(p); + calcru(p, &utime, &stime); + calccru(p, &cutime, &cstime); + PROC_UNLOCK(p); - tms.tms_utime = CONVTCK(ru.ru_utime); - tms.tms_stime = CONVTCK(ru.ru_stime); + tms.tms_utime = CONVTCK(utime); + tms.tms_stime = CONVTCK(stime); - tms.tms_cutime = CONVTCK(td->td_proc->p_stats->p_cru.ru_utime); - tms.tms_cstime = CONVTCK(td->td_proc->p_stats->p_cru.ru_stime); + tms.tms_cutime = CONVTCK(cutime); + tms.tms_cstime = CONVTCK(cstime); if ((error = copyout(&tms, args->buf, sizeof(tms)))) return error; @@ -851,7 +853,7 @@ linux_wait4(struct thread *td, struct linux_wait4_args *args) { int error, options, tmpstat; - struct rusage ru; + struct rusage ru, *rup; struct proc *p; #ifdef DEBUG @@ -866,7 +868,11 @@ if (args->options & __WCLONE) options |= WLINUXCLONE; - error = kern_wait(td, args->pid, &tmpstat, options, &ru); + if (args->rusage != NULL) + rup = &ru; + else + rup = NULL; + error = kern_wait(td, args->pid, &tmpstat, options, rup); if (error) return error; ==== //depot/projects/nsched/sys/compat/svr4/svr4_misc.c#3 (text+ko) ==== @@ -33,7 +33,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_misc.c,v 1.73 2004/09/24 20:26:15 jhb Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/svr4/svr4_misc.c,v 1.74 2004/10/05 18:51:10 jhb Exp $"); #include "opt_mac.h" @@ -861,44 +861,30 @@ struct thread *td; struct svr4_sys_times_args *uap; { - int error, *retval = td->td_retval; - struct tms tms; - struct timeval t; - struct rusage *ru; - struct rusage r; - struct getrusage_args ga; + struct timeval tv, utime, stime, cutime, cstime; + struct tms tms; + struct proc *p; + int error; - caddr_t sg = stackgap_init(); - ru = stackgap_alloc(&sg, sizeof(struct rusage)); + p = td->td_proc; + PROC_LOCK(p); + calcru(p, &utime, &stime); + calccru(p, &cutime, &cstime); + PROC_UNLOCK(p); - ga.who = RUSAGE_SELF; - ga.rusage = ru; + tms.tms_utime = timeval_to_clock_t(&utime); + tms.tms_stime = timeval_to_clock_t(&stime); - error = getrusage(td, &ga); - if (error) - return error; + tms.tms_cutime = timeval_to_clock_t(&cutime); + tms.tms_cstime = timeval_to_clock_t(&cstime); - if ((error = copyin(ru, &r, sizeof r)) != 0) - return error; - - tms.tms_utime = timeval_to_clock_t(&r.ru_utime); - tms.tms_stime = timeval_to_clock_t(&r.ru_stime); - - ga.who = RUSAGE_CHILDREN; - error = getrusage(td, &ga); + error = copyout(&tms, uap->tp, sizeof(tms)); if (error) - return error; + return (error); - if ((error = copyin(ru, &r, sizeof r)) != 0) - return error; - - tms.tms_cutime = timeval_to_clock_t(&r.ru_utime); - tms.tms_cstime = timeval_to_clock_t(&r.ru_stime); - - microtime(&t); - *retval = timeval_to_clock_t(&t); - - return copyout(&tms, uap->tp, sizeof(tms)); + microtime(&tv); + td->td_retval[0] = (int)timeval_to_clock_t(&tv); + return (0); } @@ -1149,6 +1135,7 @@ int st; svr4_siginfo_t *s; { + struct timeval utime, stime; svr4_siginfo_t i; int sig; @@ -1159,16 +1146,11 @@ if (p) { i.si_pid = p->p_pid; - mtx_lock_spin(&sched_lock); - if (p->p_state == PRS_ZOMBIE) { - i.si_stime = p->p_ru->ru_stime.tv_sec; - i.si_utime = p->p_ru->ru_utime.tv_sec; - } - else { - i.si_stime = p->p_stats->p_ru.ru_stime.tv_sec; - i.si_utime = p->p_stats->p_ru.ru_utime.tv_sec; - } - mtx_unlock_spin(&sched_lock); + PROC_LOCK(p); + calcru(p, &utime, &stime); + PROC_UNLOCK(p); + i.si_stime = stime.tv_sec; + i.si_utime = utime.tv_sec; } if (WIFEXITED(st)) { @@ -1296,7 +1278,8 @@ PROC_UNLOCK(q); sx_xunlock(&proctree_lock); q->p_xstat = 0; - ruadd(&p->p_stats->p_cru, q->p_ru); + ruadd(&p->p_stats->p_cru, &p->p_crux, q->p_ru, + &q->p_rux); FREE(q->p_ru, M_ZOMBIE); q->p_ru = NULL; ==== //depot/projects/nsched/sys/conf/NOTES#22 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/NOTES,v 1.1279 2004/09/23 08:34:50 phk Exp $ +# $FreeBSD: src/sys/conf/NOTES,v 1.1281 2004/10/04 14:16:17 yar Exp $ # # NOTES -- Lines that can be cut/pasted into kernel and hints configs. # @@ -514,6 +514,8 @@ # The `ether' device provides generic code to handle # Ethernets; it is MANDATORY when an Ethernet device driver is # configured or token-ring is enabled. +# The `vlan' device implements the VLAN tagging of Ethernet frames +# according to IEEE 802.1Q. It requires `device miibus'. # The `wlan' device provides generic code to support 802.11 # drivers, including host AP mode; it is MANDATORY for the wi # driver and will eventually be required by all 802.11 drivers. @@ -558,7 +560,7 @@ # See pppd(8) for more details. # device ether #Generic Ethernet -device vlan #VLAN support +device vlan #VLAN support (needs miibus) device wlan #802.11 support device token #Generic TokenRing device fddi #Generic FDDI ==== //depot/projects/nsched/sys/dev/cy/cy.c#10 (text+ko) ==== @@ -29,7 +29,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/cy/cy.c,v 1.159 2004/07/15 20:47:37 phk Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/cy/cy.c,v 1.160 2004/10/05 07:42:19 phk Exp $"); #include "opt_compat.h" @@ -77,6 +77,7 @@ #include #include #include +#include #include #include @@ -89,51 +90,7 @@ #define NCY 10 /* KLUDGE */ -/* - * Dictionary so that I can name everything *sio* or *com* to compare with - * sio.c. There is also lots of ugly formatting and unnecessary ifdefs to - * simplify the comparision. These will go away. - */ -#define LSR_BI CD1400_RDSR_BREAK -#define LSR_FE CD1400_RDSR_FE -#define LSR_OE CD1400_RDSR_OE -#define LSR_PE CD1400_RDSR_PE -#define MCR_DTR CD1400_MSVR2_DTR -#define MCR_RTS CD1400_MSVR1_RTS -#define MSR_CTS CD1400_MSVR2_CTS -#define MSR_DCD CD1400_MSVR2_CD -#define MSR_DSR CD1400_MSVR2_DSR -#define MSR_RI CD1400_MSVR2_RI -#define NSIO (NCY * CY_MAX_PORTS) -#define comconsole cyconsole -#define comdefaultrate cydefaultrate -#define com_events cy_events -#define comhardclose cyhardclose -#define commctl cymctl -#define comparam cyparam -#define comspeed cyspeed -#define comstart cystart -#define comwakeup cywakeup -#define p_com_addr p_cy_addr -#define sioclose cyclose -#define siodriver cydriver -#define sioinput cyinput -#define siointr1 cyintr -#define sioioctl cyioctl -#define sioopen cyopen -#define siopoll cypoll -#define siosettimeout cysettimeout -#define siosetwater cysetwater -#define comstop cystop -#define siowrite cywrite -#define sio_fast_ih cy_fast_ih -#define sio_inited cy_inited -#define sio_irec cy_irec -#define sio_lock cy_lock -#define sio_slow_ih cy_slow_ih -#define sio_timeout cy_timeout -#define sio_timeout_handle cy_timeout_handle -#define sio_timeouts_until_log cy_timeouts_until_log +#define NPORTS (NCY * CY_MAX_PORTS) #define CY_MAX_PORTS (CD1400_NO_OF_CHANNELS * CY_MAX_CD1400s) @@ -153,34 +110,18 @@ #define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */ -#define CALLOUT_MASK 0x80 -#define CONTROL_MASK 0x60 -#define CONTROL_INIT_STATE 0x20 -#define CONTROL_LOCK_STATE 0x40 -#define DEV_TO_UNIT(dev) (MINOR_TO_UNIT(minor(dev))) -#define MINOR_MAGIC_MASK (CALLOUT_MASK | CONTROL_MASK) /* - * Not all of the magic is parametrized in the following macros. 16 and - * 0xff are related to the bitfields in a dev_t. CY_MAX_PORTS must be - * ((0xff & ~MINOR_MAGIC_MASK) + 1) for things to work. - */ -#define MINOR_TO_UNIT(mynor) (((mynor) >> 16) * CY_MAX_PORTS \ - | (((mynor) & 0xff) & ~MINOR_MAGIC_MASK)) -#define UNIT_TO_MINOR(unit) (((unit) / CY_MAX_PORTS) << 16 \ - | (((unit) & 0xff) & ~MINOR_MAGIC_MASK)) - -/* * com state bits. * (CS_BUSY | CS_TTGO) and (CS_BUSY | CS_TTGO | CS_ODEVREADY) must be higher * than the other bits so that they can be tested as a group without masking * off the low bits. * * The following com and tty flags correspond closely: - * CS_BUSY = TS_BUSY (maintained by comstart(), siopoll() and + * CS_BUSY = TS_BUSY (maintained by cystart(), cypoll() and * comstop()) - * CS_TTGO = ~TS_TTSTOP (maintained by comparam() and comstart()) - * CS_CTS_OFLOW = CCTS_OFLOW (maintained by comparam()) - * CS_RTS_IFLOW = CRTS_IFLOW (maintained by comparam()) + * CS_TTGO = ~TS_TTSTOP (maintained by cyparam() and cystart()) + * CS_CTS_OFLOW = CCTS_OFLOW (maintained by cyparam()) + * CS_RTS_IFLOW = CRTS_IFLOW (maintained by cyparam()) * TS_FLUSH is not used. * XXX I think TIOCSETA doesn't clear TS_TTSTOP when it clears IXON. * XXX CS_*FLOW should be CF_*FLOW in com->flags (control flags not state). @@ -207,8 +148,8 @@ #define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum]) #ifdef SMP -#define COM_LOCK() mtx_lock_spin(&sio_lock) -#define COM_UNLOCK() mtx_unlock_spin(&sio_lock) +#define COM_LOCK() mtx_lock_spin(&cy_lock) +#define COM_UNLOCK() mtx_unlock_spin(&cy_lock) #else #define COM_LOCK() #define COM_UNLOCK() @@ -228,36 +169,13 @@ /* com device structure */ struct com_s { u_char state; /* miscellaneous flag bits */ - bool_t active_out; /* nonzero if the callout device is open */ -#if 0 - u_char cfcr_image; /* copy of value written to CFCR */ -#endif u_char etc; /* pending Embedded Transmit Command */ u_char extra_state; /* more flag bits, separate for order trick */ -#if 0 - u_char fifo_image; /* copy of value written to FIFO */ -#endif u_char gfrcr_image; /* copy of value read from GFRCR */ -#if 0 - bool_t hasfifo; /* nonzero for 16550 UARTs */ - bool_t loses_outints; /* nonzero if device loses output interrupts */ -#endif u_char mcr_dtr; /* MCR bit that is wired to DTR */ u_char mcr_image; /* copy of value written to MCR */ u_char mcr_rts; /* MCR bit that is wired to RTS */ -#if 0 -#ifdef COM_MULTIPORT - bool_t multiport; /* is this unit part of a multiport device? */ -#endif /* COM_MULTIPORT */ - bool_t no_irq; /* nonzero if irq is not attached */ - bool_t poll; /* nonzero if polling is required */ - bool_t poll_output; /* nonzero if polling for output is required */ -#endif int unit; /* unit number */ -#if 0 - u_int tx_fifo_size; -#endif - u_int wopeners; /* # processes waiting for DCD in open() */ /* * The high level of the driver never reads status registers directly @@ -286,17 +204,6 @@ struct tty *tp; /* cross reference */ - /* Initial state. */ - struct termios it_in; /* should be in struct tty */ - struct termios it_out; - - /* Lock state. */ - struct termios lt_in; /* should be in struct tty */ - struct termios lt_out; - - bool_t do_timestamp; - struct timeval timestamp; - u_long bytes_in; /* statistics */ u_long bytes_out; u_int delta_error_counts[CE_NTYPES]; @@ -305,7 +212,7 @@ u_int recv_exception; /* exception chars received */ u_int mdm; /* modem signal changes */ #ifdef CyDebug - u_int start_count; /* no. of calls to comstart() */ + u_int start_count; /* no. of calls to cystart() */ u_int start_real; /* no. of calls that did something */ #endif u_char car; /* CD1400 CAR shadow (if first unit in cd) */ @@ -329,55 +236,41 @@ static void cd_etc(struct com_s *com, int etc); static int cd_getreg(struct com_s *com, int reg); static void cd_setreg(struct com_s *com, int reg, int val); -static void comhardclose(struct com_s *com); -static void sioinput(struct com_s *com); -static int commctl(struct com_s *com, int bits, int how); -static int comparam(struct tty *tp, struct termios *t); -static void siopoll(void *arg); -static void siosettimeout(void); -static int siosetwater(struct com_s *com, speed_t speed); -static int comspeed(speed_t speed, u_long cy_clock, int *prescaler_io); -static void comstart(struct tty *tp); +static void cyinput(struct com_s *com); +static int cyparam(struct tty *tp, struct termios *t); +static void cypoll(void *arg); +static void cysettimeout(void); +static int cysetwater(struct com_s *com, speed_t speed); +static int cyspeed(speed_t speed, u_long cy_clock, int *prescaler_io); +static void cystart(struct tty *tp); static void comstop(struct tty *tp, int rw); -static timeout_t comwakeup; +static timeout_t cywakeup; static void disc_optim(struct tty *tp, struct termios *t, struct com_s *com); +static t_break_t cybreak; +static t_modem_t cymodem; +static t_open_t cyopen; +static t_close_t cyclose; + #ifdef CyDebug void cystatus(int unit); #endif -static struct mtx sio_lock; -static int sio_inited; +static struct mtx cy_lock; +static int cy_inited; /* table and macro for fast conversion from a unit number to its com struct */ -static struct com_s *p_com_addr[NSIO]; -#define com_addr(unit) (p_com_addr[unit]) +static struct com_s *p_cy_addr[NPORTS]; +#define cy_addr(unit) (p_cy_addr[unit]) -static d_open_t sioopen; -static d_close_t sioclose; -static d_write_t siowrite; -static d_ioctl_t sioioctl; - -static struct cdevsw sio_cdevsw = { - .d_version = D_VERSION, - .d_open = sioopen, - .d_close = sioclose, - .d_write = siowrite, - .d_ioctl = sioioctl, - .d_name = cy_driver_name, - .d_flags = D_TTY | D_NEEDGIANT, -}; - -static int comconsole = -1; -static speed_t comdefaultrate = TTYDEF_SPEED; -static u_int com_events; /* input chars + weighted output completions */ -static void *sio_fast_ih; -static void *sio_slow_ih; -static int sio_timeout; -static int sio_timeouts_until_log; -static struct callout_handle sio_timeout_handle - = CALLOUT_HANDLE_INITIALIZER(&sio_timeout_handle); +static u_int cy_events; /* input chars + weighted output completions */ +static void *cy_fast_ih; +static void *cy_slow_ih; +static int cy_timeout; +static int cy_timeouts_until_log; +static struct callout_handle cy_timeout_handle + = CALLOUT_HANDLE_INITIALIZER(&cy_timeout_handle); #ifdef CyDebug static u_int cd_inbs; @@ -397,9 +290,7 @@ static int volatile RxFifoThreshold = (CD1400_RX_FIFO_SIZE / 2); int -cy_units(cy_iobase, cy_align) - cy_addr cy_iobase; - int cy_align; +cy_units(cy_addr cy_iobase, int cy_align) { int cyu; u_char firmware_version; @@ -449,22 +340,20 @@ } void * -cyattach_common(cy_iobase, cy_align) - cy_addr cy_iobase; - int cy_align; +cyattach_common(cy_addr cy_iobase, int cy_align) { int adapter; int cyu; u_char firmware_version; cy_addr iobase; - int minorbase; int ncyu; int unit; + struct tty *tp; - while (sio_inited != 2) - if (atomic_cmpset_int(&sio_inited, 0, 1)) { - mtx_init(&sio_lock, cy_driver_name, NULL, MTX_SPIN); - atomic_store_rel_int(&sio_inited, 2); + while (cy_inited != 2) + if (atomic_cmpset_int(&cy_inited, 0, 1)) { + mtx_init(&cy_lock, cy_driver_name, NULL, MTX_SPIN); + atomic_store_rel_int(&cy_inited, 2); } adapter = cy_total_devices; @@ -497,325 +386,116 @@ struct com_s *com; int s; - com = malloc(sizeof *com, M_DEVBUF, M_NOWAIT | M_ZERO); - if (com == NULL) - break; - com->unit = unit; + com = malloc(sizeof *com, M_DEVBUF, M_NOWAIT | M_ZERO); + if (com == NULL) + break; + com->unit = unit; com->gfrcr_image = firmware_version; if (CY_RTS_DTR_SWAPPED(firmware_version)) { - com->mcr_dtr = MCR_RTS; - com->mcr_rts = MCR_DTR; + com->mcr_dtr = CD1400_MSVR1_RTS; + com->mcr_rts = CD1400_MSVR2_DTR; com->mcr_rts_reg = CD1400_MSVR2; } else { - com->mcr_dtr = MCR_DTR; - com->mcr_rts = MCR_RTS; + com->mcr_dtr = CD1400_MSVR2_DTR; + com->mcr_rts = CD1400_MSVR1_RTS; com->mcr_rts_reg = CD1400_MSVR1; } - com->obufs[0].l_head = com->obuf1; - com->obufs[1].l_head = com->obuf2; + com->obufs[0].l_head = com->obuf1; + com->obufs[1].l_head = com->obuf2; com->cy_align = cy_align; com->cy_iobase = cy_iobase; - com->iobase = iobase; + com->iobase = iobase; com->car = ~CD1400_CAR_CHAN; - /* - * We don't use all the flags from since they - * are only relevant for logins. It's important to have echo off - * initially so that the line doesn't start blathering before the - * echo flag can be turned off. - */ - com->it_in.c_iflag = 0; - com->it_in.c_oflag = 0; - com->it_in.c_cflag = TTYDEF_CFLAG; - com->it_in.c_lflag = 0; - if (unit == comconsole) { - com->it_in.c_iflag = TTYDEF_IFLAG; - com->it_in.c_oflag = TTYDEF_OFLAG; - com->it_in.c_cflag = TTYDEF_CFLAG | CLOCAL; - com->it_in.c_lflag = TTYDEF_LFLAG; - com->lt_out.c_cflag = com->lt_in.c_cflag = CLOCAL; - } - if (siosetwater(com, com->it_in.c_ispeed) != 0) { - free(com, M_DEVBUF); - return (NULL); - } - termioschars(&com->it_in); - com->it_in.c_ispeed = com->it_in.c_ospeed = comdefaultrate; - com->it_out = com->it_in; + tp = com->tp = ttyalloc(); + tp->t_open = cyopen; + tp->t_close = cyclose; + tp->t_oproc = cystart; + tp->t_stop = comstop; + tp->t_param = cyparam; + tp->t_break = cybreak; + tp->t_modem = cymodem; + tp->t_sc = com; + + if (cysetwater(com, tp->t_init_in.c_ispeed) != 0) { + free(com, M_DEVBUF); + return (NULL); + } - s = spltty(); - com_addr(unit) = com; - splx(s); + s = spltty(); + cy_addr(unit) = com; + splx(s); - if (sio_fast_ih == NULL) { - swi_add(&tty_ithd, "cy", siopoll, NULL, SWI_TTY, 0, - &sio_fast_ih); - swi_add(&clk_ithd, "cy", siopoll, NULL, SWI_CLOCK, 0, - &sio_slow_ih); - } - minorbase = UNIT_TO_MINOR(unit); - make_dev(&sio_cdevsw, minorbase, - UID_ROOT, GID_WHEEL, 0600, "ttyc%r%r", adapter, - unit % CY_MAX_PORTS); - make_dev(&sio_cdevsw, minorbase | CONTROL_INIT_STATE, - UID_ROOT, GID_WHEEL, 0600, "ttyic%r%r", adapter, - unit % CY_MAX_PORTS); - make_dev(&sio_cdevsw, minorbase | CONTROL_LOCK_STATE, - UID_ROOT, GID_WHEEL, 0600, "ttylc%r%r", adapter, - unit % CY_MAX_PORTS); - make_dev(&sio_cdevsw, minorbase | CALLOUT_MASK, >>> TRUNCATED FOR MAIL (1000 lines) <<<