From imp at FreeBSD.org Tue Oct 7 23:55:32 2008 From: imp at FreeBSD.org (Warner Losh) Date: Tue Oct 7 23:55:44 2008 Subject: svn commit: r183678 - head/sys/dev/aha Message-ID: <200810072355.m97NtWBA015383@svn.freebsd.org> Author: imp Date: Tue Oct 7 23:55:32 2008 New Revision: 183678 URL: http://svn.freebsd.org/changeset/base/183678 Log: Pass bus_get_dma_tag() into the first argument of bus_dma_create_tag() rather than NULL. Modified: head/sys/dev/aha/aha_isa.c head/sys/dev/aha/aha_mca.c Modified: head/sys/dev/aha/aha_isa.c ============================================================================== --- head/sys/dev/aha/aha_isa.c Tue Oct 7 22:15:29 2008 (r183677) +++ head/sys/dev/aha/aha_isa.c Tue Oct 7 23:55:32 2008 (r183678) @@ -231,7 +231,7 @@ aha_isa_attach(device_t dev) filter_arg = NULL; lowaddr = BUS_SPACE_MAXADDR_24BIT; - if (bus_dma_tag_create( /* parent */ NULL, + if (bus_dma_tag_create( /* parent */ bus_get_dma_tag(dev), /* alignemnt */ 1, /* boundary */ 0, /* lowaddr */ lowaddr, Modified: head/sys/dev/aha/aha_mca.c ============================================================================== --- head/sys/dev/aha/aha_mca.c Tue Oct 7 22:15:29 2008 (r183677) +++ head/sys/dev/aha/aha_mca.c Tue Oct 7 23:55:32 2008 (r183678) @@ -162,7 +162,7 @@ aha_mca_attach (device_t dev) isa_dmacascade(rman_get_start(sc->drq)); error = bus_dma_tag_create( - /* parent */ NULL, + /* parent */ bus_get_dma_tag(dev), /* alignemnt */ 1, /* boundary */ 0, /* lowaddr */ BUS_SPACE_MAXADDR_24BIT, From delphij at FreeBSD.org Wed Oct 8 01:31:00 2008 From: delphij at FreeBSD.org (Xin LI) Date: Wed Oct 8 01:31:11 2008 Subject: svn commit: r183679 - head Message-ID: <200810080131.m981V0HR016984@svn.freebsd.org> Author: delphij Date: Wed Oct 8 01:31:00 2008 New Revision: 183679 URL: http://svn.freebsd.org/changeset/base/183679 Log: Don't mention lib/compat, it has gone long ago. Use ports/misc/compat* instead. Modified: head/UPDATING Modified: head/UPDATING ============================================================================== --- head/UPDATING Tue Oct 7 23:55:32 2008 (r183678) +++ head/UPDATING Wed Oct 8 01:31:00 2008 (r183679) @@ -59,6 +59,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8. option to "ssh-dss,ssh-rsa" in ~/.ssh/config or on the ssh command line. + Please note that the sequence of keys offered for + authentication has been changed as well. You may want to + specify IdentityFile in a different order to revert this + behavior. + 20080713: The sio(4) driver has been removed from the i386 and amd64 kernel configuration files. This means uart(4) is now the @@ -1018,7 +1023,7 @@ COMMON ITEMS: - + From peter at FreeBSD.org Wed Oct 8 04:12:39 2008 From: peter at FreeBSD.org (Peter Wemm) Date: Wed Oct 8 04:12:45 2008 Subject: svn commit: r183683 - svnadmin/conf Message-ID: <200810080412.m984CdLZ020104@svn.freebsd.org> Author: peter Date: Wed Oct 8 04:12:38 2008 New Revision: 183683 URL: http://svn.freebsd.org/changeset/base/183683 Log: Add svnadmin group Modified: svnadmin/conf/mailer.conf Modified: svnadmin/conf/mailer.conf ============================================================================== --- svnadmin/conf/mailer.conf Wed Oct 8 04:08:17 2008 (r183682) +++ svnadmin/conf/mailer.conf Wed Oct 8 04:12:38 2008 (r183683) @@ -334,6 +334,10 @@ truncate_subject = 200 # to_addr = %(who)s@example.com # +[svnadmin] +for_paths = svnadmin/.* +to_addr = src-committers@freebsd.org svn-src-all@freebsd.org svn-src-head@freebsd.org + [head] for_paths = head/.* to_addr = src-committers@freebsd.org svn-src-all@freebsd.org svn-src-head@freebsd.org From peter at FreeBSD.org Wed Oct 8 04:20:29 2008 From: peter at FreeBSD.org (Peter Wemm) Date: Wed Oct 8 04:20:41 2008 Subject: svn commit: r183684 - svnadmin/hooks/scripts Message-ID: <200810080420.m984KTkN020305@svn.freebsd.org> Author: peter Date: Wed Oct 8 04:20:28 2008 New Revision: 183684 URL: http://svn.freebsd.org/changeset/base/183684 Log: Emit a mail header to indicate which mailer.conf group triggered the message. Modified: svnadmin/hooks/scripts/mailer.py Modified: svnadmin/hooks/scripts/mailer.py ============================================================================== --- svnadmin/hooks/scripts/mailer.py Wed Oct 8 04:12:38 2008 (r183683) +++ svnadmin/hooks/scripts/mailer.py Wed Oct 8 04:20:28 2008 (r183684) @@ -243,10 +243,11 @@ class MailedOutput(OutputBase): # hdrs = 'From: %s\n' \ # hdrs = 'To: %s\n' \ hdrs = 'Subject: %s\n' \ + 'X-SVN-Group: %s\n' \ 'MIME-Version: 1.0\n' \ 'Content-Type: text/plain; charset=UTF-8\n' \ 'Content-Transfer-Encoding: 8bit\n' \ - % (subject) + % (subject, group or "defaults") # % (self.from_addr, string.join(self.to_addrs, ', '), subject) if self.reply_to: hdrs = '%sReply-To: %s\n' % (hdrs, self.reply_to) From peter at FreeBSD.org Wed Oct 8 04:27:04 2008 From: peter at FreeBSD.org (Peter Wemm) Date: Wed Oct 8 04:27:16 2008 Subject: svn commit: r183685 - svnadmin/conf Message-ID: <200810080427.m984R47d020535@svn.freebsd.org> Author: peter Date: Wed Oct 8 04:27:03 2008 New Revision: 183685 URL: http://svn.freebsd.org/changeset/base/183685 Log: The commit mail generator generates two separate commit mails for commits that cross multiple parts of the tree. There is no need to show the diffs multiple times. Modified: svnadmin/conf/mailer.conf Modified: svnadmin/conf/mailer.conf ============================================================================== --- svnadmin/conf/mailer.conf Wed Oct 8 04:20:28 2008 (r183684) +++ svnadmin/conf/mailer.conf Wed Oct 8 04:27:03 2008 (r183685) @@ -240,7 +240,7 @@ commit_url = http://svn.freebsd.org/chan # summary: Show the changed paths in the summary, but omit the diffs. # no: Show nothing more than a note saying "and changes in other areas" # -show_nonmatching_paths = yes +show_nonmatching_paths = summary # Subject line length limit. The generated subject line will be truncated # and terminated with "...", to remain within the specified maximum length. From rwatson at FreeBSD.org Wed Oct 8 06:19:49 2008 From: rwatson at FreeBSD.org (Robert Watson) Date: Wed Oct 8 06:20:01 2008 Subject: svn commit: r183689 - head/sys/kern Message-ID: <200810080619.m986JnpQ024072@svn.freebsd.org> Author: rwatson Date: Wed Oct 8 06:19:49 2008 New Revision: 183689 URL: http://svn.freebsd.org/changeset/base/183689 Log: Differentiate pr_usrreqs for stream and datagram UNIX domain sockets, and employ soreceive_dgram for the datagram case. MFC after: 3 months Modified: head/sys/kern/uipc_usrreq.c Modified: head/sys/kern/uipc_usrreq.c ============================================================================== --- head/sys/kern/uipc_usrreq.c Wed Oct 8 05:30:30 2008 (r183688) +++ head/sys/kern/uipc_usrreq.c Wed Oct 8 06:19:49 2008 (r183689) @@ -249,20 +249,20 @@ static struct mbuf *unp_addsockcred(stru * Definitions of protocols supported in the LOCAL domain. */ static struct domain localdomain; -static struct pr_usrreqs uipc_usrreqs; +static struct pr_usrreqs uipc_usrreqs_dgram, uipc_usrreqs_stream; static struct protosw localsw[] = { { .pr_type = SOCK_STREAM, .pr_domain = &localdomain, .pr_flags = PR_CONNREQUIRED|PR_WANTRCVD|PR_RIGHTS, .pr_ctloutput = &uipc_ctloutput, - .pr_usrreqs = &uipc_usrreqs + .pr_usrreqs = &uipc_usrreqs_stream }, { .pr_type = SOCK_DGRAM, .pr_domain = &localdomain, .pr_flags = PR_ATOMIC|PR_ADDR|PR_RIGHTS, - .pr_usrreqs = &uipc_usrreqs + .pr_usrreqs = &uipc_usrreqs_dgram }, }; @@ -996,7 +996,7 @@ uipc_sockaddr(struct socket *so, struct return (0); } -static struct pr_usrreqs uipc_usrreqs = { +static struct pr_usrreqs uipc_usrreqs_dgram = { .pru_abort = uipc_abort, .pru_accept = uipc_accept, .pru_attach = uipc_attach, @@ -1012,6 +1012,27 @@ static struct pr_usrreqs uipc_usrreqs = .pru_sense = uipc_sense, .pru_shutdown = uipc_shutdown, .pru_sockaddr = uipc_sockaddr, + .pru_soreceive = soreceive_dgram, + .pru_close = uipc_close, +}; + +static struct pr_usrreqs uipc_usrreqs_stream = { + .pru_abort = uipc_abort, + .pru_accept = uipc_accept, + .pru_attach = uipc_attach, + .pru_bind = uipc_bind, + .pru_connect = uipc_connect, + .pru_connect2 = uipc_connect2, + .pru_detach = uipc_detach, + .pru_disconnect = uipc_disconnect, + .pru_listen = uipc_listen, + .pru_peeraddr = uipc_peeraddr, + .pru_rcvd = uipc_rcvd, + .pru_send = uipc_send, + .pru_sense = uipc_sense, + .pru_shutdown = uipc_shutdown, + .pru_sockaddr = uipc_sockaddr, + .pru_soreceive = soreceive_generic, .pru_close = uipc_close, }; From rwatson at FreeBSD.org Wed Oct 8 06:26:52 2008 From: rwatson at FreeBSD.org (Robert Watson) Date: Wed Oct 8 06:27:04 2008 Subject: svn commit: r183690 - head/sys/kern Message-ID: <200810080626.m986Qp4U024485@svn.freebsd.org> Author: rwatson Date: Wed Oct 8 06:26:51 2008 New Revision: 183690 URL: http://svn.freebsd.org/changeset/base/183690 Log: Remove stale comment (and XXX saying so) about why we zero the file descriptor pointer in unp_freerights: we can no longer recurse into unp_gc due to unp_gc being invoked in a deferred way, but it's still a good idea. MFC after: 3 days Modified: head/sys/kern/uipc_usrreq.c Modified: head/sys/kern/uipc_usrreq.c ============================================================================== --- head/sys/kern/uipc_usrreq.c Wed Oct 8 06:19:49 2008 (r183689) +++ head/sys/kern/uipc_usrreq.c Wed Oct 8 06:26:51 2008 (r183690) @@ -1538,12 +1538,6 @@ unp_freerights(struct file **rp, int fdc struct file *fp; for (i = 0; i < fdcount; i++) { - /* - * Zero the pointer before calling unp_discard since it may - * end up in unp_gc().. - * - * XXXRW: This is less true than it used to be. - */ fp = *rp; *rp++ = NULL; unp_discard(fp); From phk at FreeBSD.org Wed Oct 8 06:39:07 2008 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed Oct 8 06:39:13 2008 Subject: svn commit: r183691 - head/games/fortune/datfiles Message-ID: <200810080639.m986d54N025194@svn.freebsd.org> Author: phk Date: Wed Oct 8 06:39:05 2008 New Revision: 183691 URL: http://svn.freebsd.org/changeset/base/183691 Log: A Wittgenstein quote according to David Ignatius http://voices.washingtonpost.com/postpartisan/2008/10/the_town_hall_debate_in_praise.html Modified: head/games/fortune/datfiles/fortunes Modified: head/games/fortune/datfiles/fortunes ============================================================================== --- head/games/fortune/datfiles/fortunes Wed Oct 8 06:26:51 2008 (r183690) +++ head/games/fortune/datfiles/fortunes Wed Oct 8 06:39:05 2008 (r183691) @@ -26583,6 +26583,9 @@ theirs, then you clearly don't understan % If you can lead it to water and force it to drink, it isn't a horse. % +If you can not say it, you can not whistle it, either. + -- Wittgenstein +% If you can read this, you're too close. % If you can survive death, you can probably survive anything. From delphij at delphij.net Wed Oct 8 07:48:53 2008 From: delphij at delphij.net (Xin LI) Date: Wed Oct 8 07:49:04 2008 Subject: svn commit: r183679 - head In-Reply-To: <200810080131.m981V0HR016984@svn.freebsd.org> References: <200810080131.m981V0HR016984@svn.freebsd.org> Message-ID: <48EC65DA.9070300@delphij.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Xin LI wrote: > Author: delphij > Date: Wed Oct 8 01:31:00 2008 > New Revision: 183679 > URL: http://svn.freebsd.org/changeset/base/183679 > > Log: > Don't mention lib/compat, it has gone long ago. Use ports/misc/compat* > instead. Oh my... I should have committed this in two parts, the first part of this ommit is to add a note regarding the recent sequence change of OpenSSH client side. > Modified: > head/UPDATING > > Modified: head/UPDATING > ============================================================================== > --- head/UPDATING Tue Oct 7 23:55:32 2008 (r183678) > +++ head/UPDATING Wed Oct 8 01:31:00 2008 (r183679) > @@ -59,6 +59,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8. > option to "ssh-dss,ssh-rsa" in ~/.ssh/config or on the ssh > command line. > > + Please note that the sequence of keys offered for > + authentication has been changed as well. You may want to > + specify IdentityFile in a different order to revert this > + behavior. > + > 20080713: > The sio(4) driver has been removed from the i386 and amd64 > kernel configuration files. This means uart(4) is now the > @@ -1018,7 +1023,7 @@ COMMON ITEMS: > > > > - > + > > > > - -- Xin LI http://www.delphij.net/ FreeBSD - The Power to Serve! -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) iEYEARECAAYFAkjsZdoACgkQi+vbBBjt66BmGwCgjeDdTcn6OGO/ArJfPhjZ7kQg b20An2uKa7u+TZGVDkEafxktAEpaF8O+ =jqiz -----END PGP SIGNATURE----- From imp at FreeBSD.org Wed Oct 8 08:08:03 2008 From: imp at FreeBSD.org (Warner Losh) Date: Wed Oct 8 08:08:14 2008 Subject: svn commit: r183692 - head/sys/dev/sio Message-ID: <200810080808.m98883NQ028095@svn.freebsd.org> Author: imp Date: Wed Oct 8 08:08:03 2008 New Revision: 183692 URL: http://svn.freebsd.org/changeset/base/183692 Log: Add a note about a bug in how sio manages its softc. This was discovered by Dorr H. Clark. I'm not at all sure how to fix it, but wanted to document it at the very least... Modified: head/sys/dev/sio/sio.c Modified: head/sys/dev/sio/sio.c ============================================================================== --- head/sys/dev/sio/sio.c Wed Oct 8 06:39:05 2008 (r183691) +++ head/sys/dev/sio/sio.c Wed Oct 8 08:08:03 2008 (r183692) @@ -696,6 +696,14 @@ sioprobe(dev, xrid, rclk, noprobe) bus_release_resource(dev, SYS_RES_IOPORT, rid, port); if (iobase == siocniobase) result = 0; + /* + * XXX: Since we don't return 0, we shouldn't be relying on + * the softc that we set to persist to the call to attach + * since other probe routines may be called, and the malloc + * here causes subr_bus to not allocate anything for the + * other probes. Instead, this softc is preserved and other + * probe routines can corrupt it. + */ if (result != 0) { device_set_softc(dev, NULL); free(com, M_DEVBUF); @@ -773,6 +781,13 @@ sioprobe(dev, xrid, rclk, noprobe) bus_release_resource(dev, SYS_RES_IOPORT, rid, port); if (iobase == siocniobase) result = 0; + /* + * XXX: Since we don't return 0, we shouldn't be relying on the softc + * that we set to persist to the call to attach since other probe + * routines may be called, and the malloc here causes subr_bus to not + * allocate anything for the other probes. Instead, this softc is + * preserved and other probe routines can corrupt it. + */ if (result != 0) { device_set_softc(dev, NULL); free(com, M_DEVBUF); From mav at FreeBSD.org Wed Oct 8 10:37:08 2008 From: mav at FreeBSD.org (Alexander Motin) Date: Wed Oct 8 10:37:21 2008 Subject: svn commit: r183693 - head/sys/netgraph/netflow Message-ID: <200810081037.m98Ab7ep031689@svn.freebsd.org> Author: mav Date: Wed Oct 8 10:37:07 2008 New Revision: 183693 URL: http://svn.freebsd.org/changeset/base/183693 Log: Add ability to generate egress netflow instead or in addition to ingress. Use mbuf tagging for accounted packets to not account packets twice when both ingress and egress netflow enabled. To keep compatibility new "setconfig" message added to control new functionality. By default node works as before, doing only ingress accounting without using mbuf tags. Reviewed by: glebius Modified: head/sys/netgraph/netflow/netflow.c head/sys/netgraph/netflow/ng_netflow.c head/sys/netgraph/netflow/ng_netflow.h Modified: head/sys/netgraph/netflow/netflow.c ============================================================================== --- head/sys/netgraph/netflow/netflow.c Wed Oct 8 08:08:03 2008 (r183692) +++ head/sys/netgraph/netflow/netflow.c Wed Oct 8 10:37:07 2008 (r183693) @@ -389,8 +389,7 @@ ng_netflow_cache_flush(priv_p priv) /* Insert packet from into flow cache. */ int -ng_netflow_flow_add(priv_p priv, struct ip *ip, iface_p iface, - struct ifnet *ifp) +ng_netflow_flow_add(priv_p priv, struct ip *ip, unsigned int src_if_index) { register struct flow_entry *fle, *fle1; struct flow_hash_entry *hsh; @@ -421,12 +420,7 @@ ng_netflow_flow_add(priv_p priv, struct r.r_ip_p = ip->ip_p; r.r_tos = ip->ip_tos; - /* Configured in_ifx overrides mbuf's */ - if (iface->info.ifinfo_index == 0) { - if (ifp != NULL) - r.r_i_ifx = ifp->if_index; - } else - r.r_i_ifx = iface->info.ifinfo_index; + r.r_i_ifx = src_if_index; /* * XXX NOTE: only first fragment of fragmented TCP, UDP and Modified: head/sys/netgraph/netflow/ng_netflow.c ============================================================================== --- head/sys/netgraph/netflow/ng_netflow.c Wed Oct 8 08:08:03 2008 (r183692) +++ head/sys/netgraph/netflow/ng_netflow.c Wed Oct 8 10:37:07 2008 (r183693) @@ -106,6 +106,14 @@ static const struct ng_parse_type ng_net &ng_netflow_settimeouts_type_fields }; +/* Parse type for ng_netflow_setconfig */ +static const struct ng_parse_struct_field ng_netflow_setconfig_type_fields[] + = NG_NETFLOW_SETCONFIG_TYPE; +static const struct ng_parse_type ng_netflow_setconfig_type = { + &ng_parse_struct_type, + &ng_netflow_setconfig_type_fields +}; + /* List of commands and how to convert arguments to/from ASCII */ static const struct ng_cmdlist ng_netflow_cmds[] = { { @@ -143,6 +151,13 @@ static const struct ng_cmdlist ng_netflo &ng_netflow_settimeouts_type, NULL }, + { + NGM_NETFLOW_COOKIE, + NGM_NETFLOW_SETCONFIG, + "setconfig", + &ng_netflow_setconfig_type, + NULL + }, { 0 } }; @@ -167,7 +182,7 @@ static int ng_netflow_constructor(node_p node) { priv_p priv; - int error = 0; + int error = 0, i; /* Initialize private data */ MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_NOWAIT); @@ -183,6 +198,10 @@ ng_netflow_constructor(node_p node) priv->info.nfinfo_inact_t = INACTIVE_TIMEOUT; priv->info.nfinfo_act_t = ACTIVE_TIMEOUT; + /* Set default config */ + for (i = 0; i < NG_NETFLOW_MAXIFACES; i++) + priv->ifaces[i].info.conf = NG_NETFLOW_CONF_INGRESS; + /* Initialize callout handle */ callout_init(&priv->exp_callout, CALLOUT_MPSAFE); @@ -399,6 +418,22 @@ ng_netflow_rcvmsg (node_p node, item_p i break; } + case NGM_NETFLOW_SETCONFIG: + { + struct ng_netflow_setconfig *set; + + if (msg->header.arglen != sizeof(struct ng_netflow_settimeouts)) + ERROUT(EINVAL); + + set = (struct ng_netflow_setconfig *)msg->data; + + if (set->iface >= NG_NETFLOW_MAXIFACES) + ERROUT(EINVAL); + + priv->ifaces[set->iface].info.conf = set->conf; + + break; + } case NGM_NETFLOW_SHOW: { uint32_t *last; @@ -445,10 +480,13 @@ ng_netflow_rcvdata (hook_p hook, item_p const node_p node = NG_HOOK_NODE(hook); const priv_p priv = NG_NODE_PRIVATE(node); const iface_p iface = NG_HOOK_PRIVATE(hook); + hook_p out; struct mbuf *m = NULL; struct ip *ip; + struct m_tag *mtag; int pullup_len = 0; - int error = 0; + int error = 0, bypass = 0; + unsigned int src_if_index; if (hook == priv->export) { /* @@ -459,16 +497,48 @@ ng_netflow_rcvdata (hook_p hook, item_p ERROUT(EINVAL); }; - if (hook == iface->out) { - /* - * Data arrived on out hook. Bypass it. - */ - if (iface->hook == NULL) + if (hook == iface->hook) { + if ((iface->info.conf & NG_NETFLOW_CONF_INGRESS) == 0) + bypass = 1; + out = iface->out; + } else if (hook == iface->out) { + if ((iface->info.conf & NG_NETFLOW_CONF_EGRESS) == 0) + bypass = 1; + out = iface->hook; + } else + ERROUT(EINVAL); + + if ((!bypass) && + (iface->info.conf & (NG_NETFLOW_CONF_ONCE | NG_NETFLOW_CONF_THISONCE))) { + mtag = m_tag_locate(NGI_M(item), MTAG_NETFLOW, + MTAG_NETFLOW_CALLED, NULL); + while (mtag != NULL) { + if ((iface->info.conf & NG_NETFLOW_CONF_ONCE) || + ((ng_ID_t *)(mtag + 1))[0] == NG_NODE_ID(node)) { + bypass = 1; + break; + } + mtag = m_tag_locate(NGI_M(item), MTAG_NETFLOW, + MTAG_NETFLOW_CALLED, mtag); + } + } + + if (bypass) { + if (out == NULL) ERROUT(ENOTCONN); - NG_FWD_ITEM_HOOK(error, item, iface->hook); + NG_FWD_ITEM_HOOK(error, item, out); return (error); } + + if (iface->info.conf & (NG_NETFLOW_CONF_ONCE | NG_NETFLOW_CONF_THISONCE)) { + mtag = m_tag_alloc(MTAG_NETFLOW, MTAG_NETFLOW_CALLED, + sizeof(ng_ID_t), M_NOWAIT); + if (mtag) { + ((ng_ID_t *)(mtag + 1))[0] = NG_NODE_ID(node); + m_tag_prepend(NGI_M(item), mtag); + } + } NGI_GET_M(item, m); @@ -592,12 +662,20 @@ ng_netflow_rcvdata (hook_p hook, item_p #undef M_CHECK - error = ng_netflow_flow_add(priv, ip, iface, m->m_pkthdr.rcvif); + /* Determine packet input interface. Prefer configured. */ + src_if_index = 0; + if (hook == iface->out || iface->info.ifinfo_index == 0) { + if (m->m_pkthdr.rcvif != NULL) + src_if_index = m->m_pkthdr.rcvif->if_index; + } else + src_if_index = iface->info.ifinfo_index; + + error = ng_netflow_flow_add(priv, ip, src_if_index); bypass: - if (iface->out != NULL) { + if (out != NULL) { /* XXX: error gets overwritten here */ - NG_FWD_NEW_DATA(error, item, iface->out, m); + NG_FWD_NEW_DATA(error, item, out, m); return (error); } done: Modified: head/sys/netgraph/netflow/ng_netflow.h ============================================================================== --- head/sys/netgraph/netflow/ng_netflow.h Wed Oct 8 08:08:03 2008 (r183692) +++ head/sys/netgraph/netflow/ng_netflow.h Wed Oct 8 10:37:07 2008 (r183693) @@ -50,6 +50,7 @@ enum { NGM_NETFLOW_SETDLT = 4, /* set data-link type */ NGM_NETFLOW_SETIFINDEX = 5, /* set interface index */ NGM_NETFLOW_SETTIMEOUTS = 6, /* set active/inactive flow timeouts */ + NGM_NETFLOW_SETCONFIG = 7, /* set flow generation options */ }; /* This structure is returned by the NGM_NETFLOW_INFO message */ @@ -71,6 +72,7 @@ struct ng_netflow_ifinfo { uint8_t ifinfo_dlt; /* Data Link Type, DLT_XXX */ #define MAXDLTNAMELEN 20 u_int16_t ifinfo_index; /* connected iface index */ + uint32_t conf; }; @@ -92,6 +94,17 @@ struct ng_netflow_settimeouts { uint32_t active_timeout; /* flow active timeout */ }; +#define NG_NETFLOW_CONF_INGRESS 1 +#define NG_NETFLOW_CONF_EGRESS 2 +#define NG_NETFLOW_CONF_ONCE 4 +#define NG_NETFLOW_CONF_THISONCE 8 + +/* This structure is passed to NGM_NETFLOW_SETCONFIG */ +struct ng_netflow_setconfig { + u_int16_t iface; /* which iface config change */ + u_int32_t conf; /* new config */ +}; + /* This is unique data, which identifies flow */ struct flow_rec { struct in_addr r_src; @@ -182,6 +195,7 @@ struct flow_entry { { "packets", &ng_parse_uint32_type }, \ { "data link type", &ng_parse_uint8_type }, \ { "index", &ng_parse_uint16_type }, \ + { "conf", &ng_parse_uint32_type }, \ { NULL } \ } @@ -206,6 +220,13 @@ struct flow_entry { { NULL } \ } +/* Parse the setifindex structure */ +#define NG_NETFLOW_SETCONFIG_TYPE { \ + { "iface", &ng_parse_uint16_type }, \ + { "conf", &ng_parse_uint32_type }, \ + { NULL } \ +} + /* Private hook data */ struct ng_netflow_iface { hook_p hook; /* NULL when disconnected */ @@ -263,12 +284,15 @@ struct flow_hash_entry { #define ERROUT(x) { error = (x); goto done; } +#define MTAG_NETFLOW 1221656444 +#define MTAG_NETFLOW_CALLED 0 + /* Prototypes for netflow.c */ int ng_netflow_cache_init(priv_p); void ng_netflow_cache_flush(priv_p); void ng_netflow_copyinfo(priv_p, struct ng_netflow_info *); timeout_t ng_netflow_expire; -int ng_netflow_flow_add(priv_p, struct ip *, iface_p, struct ifnet *); +int ng_netflow_flow_add(priv_p, struct ip *, unsigned int src_if_index); int ng_netflow_flow_show(priv_p, uint32_t last, struct ng_mesg *); #endif /* _KERNEL */ From kib at FreeBSD.org Wed Oct 8 11:11:37 2008 From: kib at FreeBSD.org (Konstantin Belousov) Date: Wed Oct 8 11:11:48 2008 Subject: svn commit: r183694 - head/sys/kern Message-ID: <200810081111.m98BBaJe032331@svn.freebsd.org> Author: kib Date: Wed Oct 8 11:11:36 2008 New Revision: 183694 URL: http://svn.freebsd.org/changeset/base/183694 Log: If the ABI-overriden interpreter was not loaded, do not set have_interp to TRUE. This allows the code in image activator to try /libexec/ld-elf.so.1 as interpreter when newinterp is not found to execute. Reviewed by: peter MFC after: 2 weeks (together with r175105) Modified: head/sys/kern/imgact_elf.c Modified: head/sys/kern/imgact_elf.c ============================================================================== --- head/sys/kern/imgact_elf.c Wed Oct 8 10:37:07 2008 (r183693) +++ head/sys/kern/imgact_elf.c Wed Oct 8 11:11:36 2008 (r183694) @@ -813,7 +813,8 @@ __CONCAT(exec_, __elfN(imgact))(struct i if (!have_interp && newinterp != NULL) { error = __elfN(load_file)(imgp->proc, newinterp, &addr, &imgp->entry_addr, sv->sv_pagesize); - have_interp = TRUE; + if (error == 0) + have_interp = TRUE; } if (!have_interp) { error = __elfN(load_file)(imgp->proc, interp, &addr, From mav at FreeBSD.org Wed Oct 8 11:19:16 2008 From: mav at FreeBSD.org (Alexander Motin) Date: Wed Oct 8 11:19:23 2008 Subject: svn commit: r183695 - head/share/man/man4 Message-ID: <200810081119.m98BJGZZ032483@svn.freebsd.org> Author: mav Date: Wed Oct 8 11:19:16 2008 New Revision: 183695 URL: http://svn.freebsd.org/changeset/base/183695 Log: Document new NGM_NETFLOW_SETCONFIG control message. Modified: head/share/man/man4/ng_netflow.4 Modified: head/share/man/man4/ng_netflow.4 ============================================================================== --- head/share/man/man4/ng_netflow.4 Wed Oct 8 11:11:36 2008 (r183694) +++ head/share/man/man4/ng_netflow.4 Wed Oct 8 11:19:16 2008 (r183695) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 2, 2006 +.Dd October 8, 2008 .Os .Dt NG_NETFLOW 4 .Sh NAME @@ -71,7 +71,8 @@ and the same number of hooks named etc., plus a single hook named .Va export . -The node does NetFlow accounting of data received on +By default (ingress NetFlow enabled) node does NetFlow accounting of data +received on .Va iface* hooks. If corresponding @@ -81,7 +82,7 @@ If data is received on .Va out hook, it is bypassed to corresponding .Va iface -hook without any processing. +hook without any processing (egress NetFlow disabled by default). When full export datagram is built it is sent to the .Va export hook. @@ -162,6 +163,31 @@ struct ng_netflow_settimeouts { uint32_t active_timeout; }; .Ed +.It Dv NGM_NETFLOW_SETCONFIG +Sets configuration for the specified interface. +This message requires +.Vt "struct ng_netflow_setconfig" +as an argument: +.Bd -literal -offset 4n +struct ng_netflow_setconfig { + u_int16_t iface; + u_int32_t conf; +#define NG_NETFLOW_CONF_INGRESS 1 +#define NG_NETFLOW_CONF_EGRESS 2 +#define NG_NETFLOW_CONF_ONCE 4 +#define NG_NETFLOW_CONF_THISONCE 8 +}; +.Ed +.Pp +Configuration is a bitmask of several options. Option NG_NETFLOW_CONF_INGRESS +enabled by default enables ingress NetFlow generation (for data coming from +ifaceX hook). Option NG_NETFLOW_CONF_EGRESS enables egress NetFlow (for data +coming from outX hook). Option NG_NETFLOW_CONF_ONCE defines that packet should +be accounted only once if it several times passes via netflow node. Option +NG_NETFLOW_CONF_THISONCE defines that packet should be accounted only once +if it several times passes via exactly this netflow node. Last two options are +important to avoid duplicate accounting when both ingress and egress NetFlow +are enabled. .It Dv NGM_NETFLOW_SHOW This control message asks a node to dump the entire contents of the flow cache. It is called from @@ -191,6 +217,8 @@ commands are: .Qq Li "setifindex { iface = %u index = %u }" .It Dv NGM_NETFLOW_SETTIMEOUTS .Qq Li "settimeouts { inactive = %u active = %u }" +.It Dv NGM_NETFLOW_SETCONFIG +.Qq Li "setconfig { iface = %u conf = %u }" .El .Sh SHUTDOWN This node shuts down upon receipt of a From des at FreeBSD.org Wed Oct 8 13:16:21 2008 From: des at FreeBSD.org (Dag-Erling Smorgrav) Date: Wed Oct 8 13:16:36 2008 Subject: svn commit: r183696 - head/gnu/usr.bin/man/man Message-ID: <200810081316.m98DGKqT034460@svn.freebsd.org> Author: des Date: Wed Oct 8 13:16:20 2008 New Revision: 183696 URL: http://svn.freebsd.org/changeset/base/183696 Log: Enable UTF-8. MFC after: 1 week Modified: head/gnu/usr.bin/man/man/man.c Modified: head/gnu/usr.bin/man/man/man.c ============================================================================== --- head/gnu/usr.bin/man/man/man.c Wed Oct 8 11:19:16 2008 (r183695) +++ head/gnu/usr.bin/man/man/man.c Wed Oct 8 13:16:20 2008 (r183696) @@ -105,6 +105,7 @@ static struct ltable ltable[] = { {"KOI8-R", "koi8-r"}, {"ISO8859-1", "latin1"}, {"ISO8859-15", "latin1"}, + {"UTF-8", "utf8"}, {NULL} }; #endif From sem at FreeBSD.org Wed Oct 8 13:19:57 2008 From: sem at FreeBSD.org (Sergey Matveychuk) Date: Wed Oct 8 13:20:33 2008 Subject: svn commit: r183693 - head/sys/netgraph/netflow In-Reply-To: <200810081037.m98Ab7ep031689@svn.freebsd.org> References: <200810081037.m98Ab7ep031689@svn.freebsd.org> Message-ID: <48ECAF7E.5040607@FreeBSD.org> Alexander Motin wrote: > Author: mav > Date: Wed Oct 8 10:37:07 2008 > New Revision: 183693 > URL: http://svn.freebsd.org/changeset/base/183693 > > Log: > Add ability to generate egress netflow instead or in addition to ingress. > Use mbuf tagging for accounted packets to not account packets twice when > both ingress and egress netflow enabled. > To keep compatibility new "setconfig" message added to control new > functionality. By default node works as before, doing only ingress > accounting without using mbuf tags. > Thanks, Alexander! I dreamed to get rid a complex construction for egress accounting. -- Dixi. Sem. From des at FreeBSD.org Wed Oct 8 13:20:07 2008 From: des at FreeBSD.org (Dag-Erling Smorgrav) Date: Wed Oct 8 13:20:43 2008 Subject: svn commit: r183697 - head/share Message-ID: <200810081320.m98DK2uY034555@svn.freebsd.org> Author: des Date: Wed Oct 8 13:20:02 2008 New Revision: 183697 URL: http://svn.freebsd.org/changeset/base/183697 Log: Whitespace nit MFC after: 1 week Modified: head/share/Makefile Modified: head/share/Makefile ============================================================================== --- head/share/Makefile Wed Oct 8 13:16:20 2008 (r183696) +++ head/share/Makefile Wed Oct 8 13:20:02 2008 (r183697) @@ -33,7 +33,7 @@ _snmp= snmp .endif .if ${MK_DICT} != "no" -_dict= dict +_dict= dict .endif .if ${MK_EXAMPLES} != "no" From des at FreeBSD.org Wed Oct 8 13:28:02 2008 From: des at FreeBSD.org (Dag-Erling Smorgrav) Date: Wed Oct 8 13:28:09 2008 Subject: svn commit: r183698 - in head/etc: . mtree Message-ID: <200810081328.m98DS2u0034724@svn.freebsd.org> Author: des Date: Wed Oct 8 13:28:02 2008 New Revision: 183698 URL: http://svn.freebsd.org/changeset/base/183698 Log: Create separate cat directories for en.UTF-8. This, together with r183697, allows users in en.UTF-8 locales to see non-ascii characters in man pages. MFC after: 1 week Modified: head/etc/Makefile head/etc/mtree/BSD.usr.dist Modified: head/etc/Makefile ============================================================================== --- head/etc/Makefile Wed Oct 8 13:20:02 2008 (r183697) +++ head/etc/Makefile Wed Oct 8 13:28:02 2008 (r183698) @@ -251,6 +251,7 @@ distrib-dirs: .endif cd ${DESTDIR}/; rm -f ${DESTDIR}/sys; ln -s usr/src/sys sys cd ${DESTDIR}/usr/share/man/en.ISO8859-1; ln -sf ../man* . + cd ${DESTDIR}/usr/share/man/en.UTF-8; ln -sf ../man* . cd ${DESTDIR}/usr/share/man; \ set - `grep "^[a-zA-Z]" ${.CURDIR}/man.alias`; \ while [ $$# -gt 0 ] ; \ Modified: head/etc/mtree/BSD.usr.dist ============================================================================== --- head/etc/mtree/BSD.usr.dist Wed Oct 8 13:20:02 2008 (r183697) +++ head/etc/mtree/BSD.usr.dist Wed Oct 8 13:28:02 2008 (r183698) @@ -740,6 +740,46 @@ cat9 .. .. + en.UTF-8 uname=root + cat1 + .. + cat1aout + .. + cat2 + .. + cat3 + .. + cat4 + amd64 + .. + arm + .. + i386 + .. + powerpc + .. + sparc64 + .. + .. + cat5 + .. + cat6 + .. + cat7 + .. + cat8 + amd64 + .. + i386 + .. + powerpc + .. + sparc64 + .. + .. + cat9 + .. + .. ja uname=root cat1 .. From phk at FreeBSD.org Wed Oct 8 13:53:47 2008 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed Oct 8 13:53:59 2008 Subject: svn commit: r183699 - head/sys/dev/usb Message-ID: <200810081353.m98DrlR6035176@svn.freebsd.org> Author: phk Date: Wed Oct 8 13:53:47 2008 New Revision: 183699 URL: http://svn.freebsd.org/changeset/base/183699 Log: Quirks for SDS-infrared.com "Hotfind-D" camera. PR: 127943 Modified: head/sys/dev/usb/umass.c head/sys/dev/usb/usbdevs Modified: head/sys/dev/usb/umass.c ============================================================================== --- head/sys/dev/usb/umass.c Wed Oct 8 13:28:02 2008 (r183698) +++ head/sys/dev/usb/umass.c Wed Oct 8 13:53:47 2008 (r183699) @@ -610,6 +610,10 @@ static struct umass_devdescr_t umass_dev UMASS_PROTO_SCSI, NO_QUIRKS }, + { USB_VENDOR_ONSPEC, USB_PRODUCT_ONSPEC_SDS_HOTFIND_D, RID_WILDCARD, + UMASS_PROTO_SCSI | UMASS_PROTO_BBB, + NO_GETMAXLUN | NO_SYNCHRONIZE_CACHE + }, { USB_VENDOR_ONSPEC, USB_PRODUCT_ONSPEC_MDCFE_B_CF_READER, RID_WILDCARD, UMASS_PROTO_SCSI, NO_QUIRKS Modified: head/sys/dev/usb/usbdevs ============================================================================== --- head/sys/dev/usb/usbdevs Wed Oct 8 13:28:02 2008 (r183698) +++ head/sys/dev/usb/usbdevs Wed Oct 8 13:53:47 2008 (r183699) @@ -1855,6 +1855,7 @@ product OMNIVISION OV511 0x0511 OV511 Ca product OMNIVISION OV511PLUS 0xa511 OV511+ Camera /* OnSpec Electronic, Inc. */ +product ONSPEC SDS_HOTFIND_D 0x0400 SDS-infrared.com Hotfind-D Infrared Camera product ONSPEC MDCFE_B_CF_READER 0xa000 MDCFE-B USB CF Reader product ONSPEC CFMS_RW 0xa001 SIIG/Datafab Memory Stick+CF Reader/Writer product ONSPEC READER 0xa003 Datafab-based Reader From des at FreeBSD.org Wed Oct 8 13:59:23 2008 From: des at FreeBSD.org (Dag-Erling Smorgrav) Date: Wed Oct 8 13:59:29 2008 Subject: svn commit: r183700 - head/share/tmac Message-ID: <200810081359.m98DxMvQ035324@svn.freebsd.org> Author: des Date: Wed Oct 8 13:59:22 2008 New Revision: 183700 URL: http://svn.freebsd.org/changeset/base/183700 Log: This directory has been empty since 1997. MFC after: 1 week Deleted: head/share/tmac/ From des at FreeBSD.org Wed Oct 8 14:45:07 2008 From: des at FreeBSD.org (Dag-Erling Smorgrav) Date: Wed Oct 8 14:45:19 2008 Subject: svn commit: r183701 - in head/contrib/groff: devX100 devX100-12 devX75 devX75-12 devascii devcp1047 devdvi devhtml devlatin1 devlbp devlj4 devps devutf8 Message-ID: <200810081445.m98Ej7X5036304@svn.freebsd.org> Author: des Date: Wed Oct 8 14:45:07 2008 New Revision: 183701 URL: http://svn.freebsd.org/changeset/base/183701 Log: These directories have been empty since 2001, and are not present in the vendor tree. MFC after: 1 week Deleted: head/contrib/groff/devX100/ head/contrib/groff/devX100-12/ head/contrib/groff/devX75/ head/contrib/groff/devX75-12/ head/contrib/groff/devascii/ head/contrib/groff/devcp1047/ head/contrib/groff/devdvi/ head/contrib/groff/devhtml/ head/contrib/groff/devlatin1/ head/contrib/groff/devlbp/ head/contrib/groff/devlj4/ head/contrib/groff/devps/ head/contrib/groff/devutf8/ From hrs at FreeBSD.org Wed Oct 8 16:46:36 2008 From: hrs at FreeBSD.org (Hiroki Sato) Date: Wed Oct 8 16:46:47 2008 Subject: svn commit: r183703 - head/release/doc/en_US.ISO8859-1/relnotes Message-ID: <200810081646.m98GkaUK038682@svn.freebsd.org> Author: hrs Date: Wed Oct 8 16:46:36 2008 New Revision: 183703 URL: http://svn.freebsd.org/changeset/base/183703 Log: OpenSSH has been upgraded to 5.1p1. Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.sgml Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.sgml ============================================================================== --- head/release/doc/en_US.ISO8859-1/relnotes/article.sgml Wed Oct 8 16:44:35 2008 (r183702) +++ head/release/doc/en_US.ISO8859-1/relnotes/article.sgml Wed Oct 8 16:46:36 2008 (r183703) @@ -445,6 +445,9 @@ ncurses has been updated from 5.6-20061217 to 5.6-20080503. + OpenSSH has been updated + from 4.5p1 to 5.1p1. + OpenPAM has been updated from the Figwort release to the Hydrangea release. From des at des.no Wed Oct 8 17:17:50 2008 From: des at des.no (=?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?=) Date: Wed Oct 8 17:18:02 2008 Subject: svn commit: r183703 - head/release/doc/en_US.ISO8859-1/relnotes In-Reply-To: <200810081646.m98GkaUK038682@svn.freebsd.org> (Hiroki Sato's message of "Wed, 8 Oct 2008 16:46:36 +0000 (UTC)") References: <200810081646.m98GkaUK038682@svn.freebsd.org> Message-ID: <86hc7nqawz.fsf@ds4.des.no> Hiroki Sato writes: > + OpenSSH has been updated > + from 4.5p1 to 5.1p1. Actually, there's quite a bit more to say about this - see UPDATING. BTW, shouldn't the HEAD relnotes only document changes relative to the latest release? DES -- Dag-Erling Sm?rgrav - des@des.no From mav at FreeBSD.org Wed Oct 8 17:35:42 2008 From: mav at FreeBSD.org (Alexander Motin) Date: Wed Oct 8 17:35:49 2008 Subject: svn commit: r183704 - head/sys/dev/mmc Message-ID: <200810081735.m98HZfoI039553@svn.freebsd.org> Author: mav Date: Wed Oct 8 17:35:41 2008 New Revision: 183704 URL: http://svn.freebsd.org/changeset/base/183704 Log: Set of mmc layer improvements: - add MMC support. - add SDHC support. - add 4 and 8 bit bus width support. - add High Speed bus timing support. Modified: head/sys/dev/mmc/bridge.h head/sys/dev/mmc/mmc.c head/sys/dev/mmc/mmcbrvar.h head/sys/dev/mmc/mmcreg.h head/sys/dev/mmc/mmcsd.c head/sys/dev/mmc/mmcvar.h Modified: head/sys/dev/mmc/bridge.h ============================================================================== --- head/sys/dev/mmc/bridge.h Wed Oct 8 16:46:36 2008 (r183703) +++ head/sys/dev/mmc/bridge.h Wed Oct 8 17:35:41 2008 (r183704) @@ -104,6 +104,10 @@ enum mmc_bus_width { bus_width_1 = 0, bus_width_4 = 2, bus_width_8 = 3 }; +enum mmc_bus_timing { + bus_timing_normal = 0, bus_timing_hs +}; + struct mmc_ios { uint32_t clock; /* Speed of the clock in Hz to move data */ enum mmc_vdd vdd; /* Voltage to apply to the power pins/ */ @@ -111,6 +115,7 @@ struct mmc_ios { enum mmc_chip_select chip_select; enum mmc_bus_width bus_width; enum mmc_power_mode power_mode; + enum mmc_bus_timing timing; }; enum mmc_card_mode { @@ -125,6 +130,7 @@ struct mmc_host { uint32_t caps; #define MMC_CAP_4_BIT_DATA (1 << 0) /* Can do 4-bit data transfers */ #define MMC_CAP_8_BIT_DATA (1 << 1) /* Can do 8-bit data transfers */ +#define MMC_CAP_HSPEED (1 << 2) /* Can do High Speed transfers */ enum mmc_card_mode mode; struct mmc_ios ios; /* Current state of the host */ }; Modified: head/sys/dev/mmc/mmc.c ============================================================================== --- head/sys/dev/mmc/mmc.c Wed Oct 8 16:46:36 2008 (r183703) +++ head/sys/dev/mmc/mmc.c Wed Oct 8 17:35:41 2008 (r183704) @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -82,11 +83,19 @@ struct mmc_softc { struct mmc_ivars { uint32_t raw_cid[4]; /* Raw bits of the CID */ uint32_t raw_csd[4]; /* Raw bits of the CSD */ + uint32_t raw_scr[2]; /* Raw bits of the SCR */ + uint8_t raw_ext_csd[512]; /* Raw bits of the EXT_CSD */ uint16_t rca; enum mmc_card_mode mode; struct mmc_cid cid; /* cid decoded */ struct mmc_csd csd; /* csd decoded */ + struct mmc_scr scr; /* scr decoded */ u_char read_only; /* True when the device is read-only */ + u_char bus_width; /* Bus width to use */ + u_char timing; /* Bus timing support */ + u_char high_cap; /* High Capacity card */ + uint32_t tran_speed; /* Max speed in normal mode */ + uint32_t hs_tran_speed; /* Max speed in high speed mode */ }; #define CMD_RETRIES 3 @@ -111,6 +120,11 @@ static int mmc_wait_for_cmd(struct mmc_s int retries); static int mmc_wait_for_command(struct mmc_softc *sc, uint32_t opcode, uint32_t arg, uint32_t flags, uint32_t *resp, int retries); +static int mmc_select_card(struct mmc_softc *sc, uint16_t rca); +static int mmc_set_bus_width(struct mmc_softc *sc, uint16_t rca, int width); +static int mmc_app_send_scr(struct mmc_softc *sc, uint16_t rca, uint32_t *rawscr); +static void mmc_app_decode_scr(uint32_t *raw_scr, struct mmc_scr *scr); +static int mmc_send_ext_csd(struct mmc_softc *sc, uint8_t *rawextcsd); static void mmc_ms_delay(int ms) @@ -173,6 +187,7 @@ static int mmc_acquire_bus(device_t busdev, device_t dev) { struct mmc_softc *sc; + struct mmc_ivars *ivar; int err; int rca; @@ -195,21 +210,26 @@ mmc_acquire_bus(device_t busdev, device_ */ rca = mmc_get_rca(dev); if (sc->last_rca != rca) { - mmc_wait_for_command(sc, MMC_SELECT_CARD, rca << 16, - MMC_RSP_R1 | MMC_CMD_AC, NULL, CMD_RETRIES); + mmc_select_card(sc, rca); sc->last_rca = rca; + /* Prepare bus width for the new card. */ + ivar = device_get_ivars(dev); + device_printf(busdev, + "setting bus width to %d bits\n", + (ivar->bus_width == bus_width_4)?4: + (ivar->bus_width == bus_width_8)?8:1); + mmc_set_bus_width(sc, rca, ivar->bus_width); + mmcbr_set_bus_width(busdev, ivar->bus_width); + mmcbr_update_ios(busdev); } - /* XXX should set bus width here? */ } else { /* * If there's a card selected, stand down. */ if (sc->last_rca != 0) { - mmc_wait_for_command(sc, MMC_SELECT_CARD, 0, - MMC_RSP_R1 | MMC_CMD_AC, NULL, CMD_RETRIES); + mmc_select_card(sc, 0); sc->last_rca = 0; } - /* XXX should set bus width here? */ } return (0); @@ -444,6 +464,22 @@ mmc_send_op_cond(struct mmc_softc *sc, u return (err); } +static int +mmc_send_if_cond(struct mmc_softc *sc, uint8_t vhs) +{ + struct mmc_command cmd; + int err; + + memset(&cmd, 0, sizeof(cmd)); + cmd.opcode = SD_SEND_IF_COND; + cmd.arg = (vhs << 8) + 0xAA; + cmd.flags = MMC_RSP_R7 | MMC_CMD_BCR; + cmd.data = NULL; + + err = mmc_wait_for_cmd(sc, &cmd, CMD_RETRIES); + return (err); +} + static void mmc_power_up(struct mmc_softc *sc) { @@ -460,6 +496,7 @@ mmc_power_up(struct mmc_softc *sc) mmc_ms_delay(1); mmcbr_set_clock(dev, mmcbr_get_f_min(sc->dev)); + mmcbr_set_timing(dev, bus_timing_normal); mmcbr_set_power_mode(dev, power_on); mmcbr_update_ios(dev); mmc_ms_delay(2); @@ -475,9 +512,207 @@ mmc_power_down(struct mmc_softc *sc) mmcbr_set_bus_width(dev, bus_width_1); mmcbr_set_power_mode(dev, power_off); mmcbr_set_clock(dev, 0); + mmcbr_set_timing(dev, bus_timing_normal); mmcbr_update_ios(dev); } +static int +mmc_select_card(struct mmc_softc *sc, uint16_t rca) +{ + return (mmc_wait_for_command(sc, MMC_SELECT_CARD, ((uint32_t)rca) << 16, + MMC_RSP_R1B | MMC_CMD_AC, NULL, CMD_RETRIES)); +} + +static int +mmc_switch(struct mmc_softc *sc, uint8_t set, uint8_t index, uint8_t value) +{ + struct mmc_command cmd; + int err; + + cmd.opcode = MMC_SWITCH_FUNC; + cmd.arg = (MMC_SWITCH_FUNC_WR << 24) | + (index << 16) | + (value << 8) | + set; + cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; + cmd.data = NULL; + err = mmc_wait_for_cmd(sc, &cmd, 0); + return (err); +} + +static int +mmc_sd_switch(struct mmc_softc *sc, uint8_t mode, uint8_t grp, uint8_t value, uint8_t *res) +{ + int err; + struct mmc_command cmd; + struct mmc_data data; + + memset(&cmd, 0, sizeof(struct mmc_command)); + memset(&data, 0, sizeof(struct mmc_data)); + + memset(res, 0, 64); + cmd.opcode = SD_SWITCH_FUNC; + cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; + cmd.arg = mode << 31; + cmd.arg |= 0x00FFFFFF; + cmd.arg &= ~(0xF << grp); + cmd.arg |= value << grp; + cmd.data = &data; + + data.data = res; + data.len = 64; + data.flags = MMC_DATA_READ; + + err = mmc_wait_for_cmd(sc, &cmd, CMD_RETRIES); + return (err); +} + +static int +mmc_set_bus_width(struct mmc_softc *sc, uint16_t rca, int width) +{ + int err; + + if (mmcbr_get_mode(sc->dev) == mode_sd) { + struct mmc_command cmd; + + memset(&cmd, 0, sizeof(struct mmc_command)); + cmd.opcode = ACMD_SET_BUS_WIDTH; + cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; + switch (width) { + case bus_width_1: + cmd.arg = SD_BUS_WIDTH_1; + break; + case bus_width_4: + cmd.arg = SD_BUS_WIDTH_4; + break; + default: + return (MMC_ERR_INVALID); + } + err = mmc_wait_for_app_cmd(sc, rca, &cmd, CMD_RETRIES); + } else { + uint8_t value; + + switch (width) { + case bus_width_1: + value = EXT_CSD_BUS_WIDTH_1; + break; + case bus_width_4: + value = EXT_CSD_BUS_WIDTH_4; + break; + case bus_width_8: + value = EXT_CSD_BUS_WIDTH_8; + break; + default: + return (MMC_ERR_INVALID); + } + err = mmc_switch(sc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH, value); + } + return (err); +} + +static int +mmc_set_timing(struct mmc_softc *sc, int timing) +{ + int err; + uint8_t value; + + switch (timing) { + case bus_timing_normal: + value = 0; + break; + case bus_timing_hs: + value = 1; + break; + default: + return (MMC_ERR_INVALID); + } + if (mmcbr_get_mode(sc->dev) == mode_sd) { + u_char switch_res[64]; + + err = mmc_sd_switch(sc, 1, 0, value, switch_res); + } else { + err = mmc_switch(sc, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_HS_TIMING, value); + } + return (err); +} + +static int +mmc_test_bus_width(struct mmc_softc *sc) +{ + struct mmc_command cmd; + struct mmc_data data; + int err; + uint8_t buf[8]; + uint8_t p8[8] = { 0x55, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + uint8_t p8ok[8] = { 0xAA, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + uint8_t p4[4] = { 0x5A, 0x00, 0x00, 0x00, }; + uint8_t p4ok[4] = { 0xA5, 0x00, 0x00, 0x00, }; + + if (mmcbr_get_caps(sc->dev) & MMC_CAP_8_BIT_DATA) { + mmcbr_set_bus_width(sc->dev, bus_width_8); + mmcbr_update_ios(sc->dev); + + cmd.opcode = MMC_BUSTEST_W; + cmd.arg = 0; + cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; + cmd.data = &data; + + data.data = p8; + data.len = 8; + data.flags = MMC_DATA_WRITE; + mmc_wait_for_cmd(sc, &cmd, 0); + + cmd.opcode = MMC_BUSTEST_R; + cmd.arg = 0; + cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; + cmd.data = &data; + + data.data = buf; + data.len = 8; + data.flags = MMC_DATA_READ; + err = mmc_wait_for_cmd(sc, &cmd, 0); + + mmcbr_set_bus_width(sc->dev, bus_width_1); + mmcbr_update_ios(sc->dev); + + if (err == MMC_ERR_NONE && memcmp(buf, p8ok, 8) == 0) + return (bus_width_8); + } + + if (mmcbr_get_caps(sc->dev) & MMC_CAP_4_BIT_DATA) { + mmcbr_set_bus_width(sc->dev, bus_width_4); + mmcbr_update_ios(sc->dev); + + cmd.opcode = MMC_BUSTEST_W; + cmd.arg = 0; + cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; + cmd.data = &data; + + data.data = p4; + data.len = 4; + data.flags = MMC_DATA_WRITE; + mmc_wait_for_cmd(sc, &cmd, 0); + + cmd.opcode = MMC_BUSTEST_R; + cmd.arg = 0; + cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; + cmd.data = &data; + + data.data = buf; + data.len = 4; + data.flags = MMC_DATA_READ; + err = mmc_wait_for_cmd(sc, &cmd, 0); + + mmcbr_set_bus_width(sc->dev, bus_width_1); + mmcbr_update_ios(sc->dev); + + if (err == MMC_ERR_NONE && memcmp(buf, p4ok, 4) == 0) + return (bus_width_4); + } + return (bus_width_1); +} + static uint32_t mmc_get_bits(uint32_t *bits, int start, int size) { @@ -506,8 +741,14 @@ mmc_decode_cid(int is_sd, uint32_t *raw_ cid->mdt_year = mmc_get_bits(raw_cid, 12, 8) + 2001; cid->mdt_month = mmc_get_bits(raw_cid, 8, 4); } else { - /* XXX write me */ - panic("write mmc cid decoder"); + cid->mid = mmc_get_bits(raw_cid, 120, 8); + cid->oid = mmc_get_bits(raw_cid, 104, 8); + for (i = 0; i < 6; i++) + cid->pnm[i] = mmc_get_bits(raw_cid, 96 - i * 8, 8); + cid->prv = mmc_get_bits(raw_cid, 48, 8); + cid->psn = mmc_get_bits(raw_cid, 16, 32); + cid->mdt_month = mmc_get_bits(raw_cid, 12, 4); + cid->mdt_year = mmc_get_bits(raw_cid, 8, 4) + 1997; } } @@ -563,12 +804,82 @@ mmc_decode_csd(int is_sd, uint32_t *raw_ csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 22, 4); csd->write_bl_partial = mmc_get_bits(raw_csd, 21, 1); } else if (v == 1) { - panic("Write SDHC CSD parser"); + m = mmc_get_bits(raw_csd, 115, 4); + e = mmc_get_bits(raw_csd, 112, 3); + csd->tacc = exp[e] * mant[m] + 9 / 10; + csd->nsac = mmc_get_bits(raw_csd, 104, 8) * 100; + m = mmc_get_bits(raw_csd, 99, 4); + e = mmc_get_bits(raw_csd, 96, 3); + csd->tran_speed = exp[e] * 10000 * mant[m]; + csd->ccc = mmc_get_bits(raw_csd, 84, 12); + csd->read_bl_len = 1 << mmc_get_bits(raw_csd, 80, 4); + csd->read_bl_partial = mmc_get_bits(raw_csd, 79, 1); + csd->write_blk_misalign = mmc_get_bits(raw_csd, 78, 1); + csd->read_blk_misalign = mmc_get_bits(raw_csd, 77, 1); + csd->dsr_imp = mmc_get_bits(raw_csd, 76, 1); + csd->capacity = ((uint64_t)mmc_get_bits(raw_csd, 48, 22) + 1) * + 512 * 1024; + csd->erase_blk_en = mmc_get_bits(raw_csd, 46, 1); + csd->sector_size = mmc_get_bits(raw_csd, 39, 7); + csd->wp_grp_size = mmc_get_bits(raw_csd, 32, 7); + csd->wp_grp_enable = mmc_get_bits(raw_csd, 31, 1); + csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 26, 3); + csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 22, 4); + csd->write_bl_partial = mmc_get_bits(raw_csd, 21, 1); } else panic("unknown SD CSD version"); } else { - panic("Write a MMC CSD parser"); + csd->csd_structure = mmc_get_bits(raw_csd, 126, 2); + csd->spec_vers = mmc_get_bits(raw_csd, 122, 4); + m = mmc_get_bits(raw_csd, 115, 4); + e = mmc_get_bits(raw_csd, 112, 3); + csd->tacc = exp[e] * mant[m] + 9 / 10; + csd->nsac = mmc_get_bits(raw_csd, 104, 8) * 100; + m = mmc_get_bits(raw_csd, 99, 4); + e = mmc_get_bits(raw_csd, 96, 3); + csd->tran_speed = exp[e] * 10000 * mant[m]; + csd->ccc = mmc_get_bits(raw_csd, 84, 12); + csd->read_bl_len = 1 << mmc_get_bits(raw_csd, 80, 4); + csd->read_bl_partial = mmc_get_bits(raw_csd, 79, 1); + csd->write_blk_misalign = mmc_get_bits(raw_csd, 78, 1); + csd->read_blk_misalign = mmc_get_bits(raw_csd, 77, 1); + csd->dsr_imp = mmc_get_bits(raw_csd, 76, 1); + csd->vdd_r_curr_min = cur_min[mmc_get_bits(raw_csd, 59, 3)]; + csd->vdd_r_curr_max = cur_max[mmc_get_bits(raw_csd, 56, 3)]; + csd->vdd_w_curr_min = cur_min[mmc_get_bits(raw_csd, 53, 3)]; + csd->vdd_w_curr_max = cur_max[mmc_get_bits(raw_csd, 50, 3)]; + m = mmc_get_bits(raw_csd, 62, 12); + e = mmc_get_bits(raw_csd, 47, 3); + csd->capacity = ((1 + m) << (e + 2)) * csd->read_bl_len; +// csd->erase_blk_en = mmc_get_bits(raw_csd, 46, 1); +// csd->sector_size = mmc_get_bits(raw_csd, 39, 7); + csd->wp_grp_size = mmc_get_bits(raw_csd, 32, 5); + csd->wp_grp_enable = mmc_get_bits(raw_csd, 31, 1); + csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 26, 3); + csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 22, 4); + csd->write_bl_partial = mmc_get_bits(raw_csd, 21, 1); + } +} + +static void +mmc_app_decode_scr(uint32_t *raw_scr, struct mmc_scr *scr) +{ + unsigned int scr_struct; + uint32_t tmp[4]; + + tmp[3] = raw_scr[1]; + tmp[2] = raw_scr[0]; + + memset(scr, 0, sizeof(*scr)); + + scr_struct = mmc_get_bits(tmp, 60, 4); + if (scr_struct != 0) { + printf("Unrecognised SCR structure version %d\n", + scr_struct); + return; } + scr->sda_vsn = mmc_get_bits(tmp, 56, 4); + scr->bus_widths = mmc_get_bits(tmp, 48, 4); } static int @@ -602,6 +913,70 @@ mmc_send_csd(struct mmc_softc *sc, uint1 } static int +mmc_app_send_scr(struct mmc_softc *sc, uint16_t rca, uint32_t *rawscr) +{ + int err; + struct mmc_command cmd; + struct mmc_data data; + + memset(&cmd, 0, sizeof(struct mmc_command)); + memset(&data, 0, sizeof(struct mmc_data)); + + memset(rawscr, 0, 8); + cmd.opcode = ACMD_SEND_SCR; + cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; + cmd.arg = 0; + cmd.data = &data; + + data.data = rawscr; + data.len = 8; + data.flags = MMC_DATA_READ; + + err = mmc_wait_for_app_cmd(sc, rca, &cmd, CMD_RETRIES); + rawscr[0] = be32toh(rawscr[0]); + rawscr[1] = be32toh(rawscr[1]); + return (err); +} + +static int +mmc_send_ext_csd(struct mmc_softc *sc, uint8_t *rawextcsd) +{ + int err; + struct mmc_command cmd; + struct mmc_data data; + + memset(&cmd, 0, sizeof(struct mmc_command)); + memset(&data, 0, sizeof(struct mmc_data)); + + memset(rawextcsd, 0, 512); + cmd.opcode = MMC_SEND_EXT_CSD; + cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; + cmd.arg = 0; + cmd.data = &data; + + data.data = rawextcsd; + data.len = 512; + data.flags = MMC_DATA_READ; + + err = mmc_wait_for_cmd(sc, &cmd, CMD_RETRIES); + return (err); +} + +static int +mmc_set_relative_addr(struct mmc_softc *sc, uint16_t resp) +{ + struct mmc_command cmd; + int err; + + cmd.opcode = MMC_SET_RELATIVE_ADDR; + cmd.arg = resp << 16; + cmd.flags = MMC_RSP_R6 | MMC_CMD_BCR; + cmd.data = NULL; + err = mmc_wait_for_cmd(sc, &cmd, 0); + return (err); +} + +static int mmc_send_relative_addr(struct mmc_softc *sc, uint32_t *resp) { struct mmc_command cmd; @@ -623,6 +998,8 @@ mmc_discover_cards(struct mmc_softc *sc) int err; uint32_t resp; device_t child; + uint16_t rca = 2; + u_char switch_res[64]; while (1) { ivar = malloc(sizeof(struct mmc_ivars), M_DEVBUF, @@ -636,22 +1013,75 @@ mmc_discover_cards(struct mmc_softc *sc) device_printf(sc->dev, "Error reading CID %d\n", err); break; } - if (mmcbr_get_mode(sc->dev) == mode_sd) { - ivar->mode = mode_sd; + if (mmcbr_get_ro(sc->dev)) + ivar->read_only = 1; + ivar->bus_width = bus_width_1; + ivar->mode = mmcbr_get_mode(sc->dev); + if (ivar->mode == mode_sd) { mmc_decode_cid(1, ivar->raw_cid, &ivar->cid); mmc_send_relative_addr(sc, &resp); ivar->rca = resp >> 16; - if (mmcbr_get_ro(sc->dev)) - ivar->read_only = 1; + /* Get card CSD. */ mmc_send_csd(sc, ivar->rca, ivar->raw_csd); mmc_decode_csd(1, ivar->raw_csd, &ivar->csd); - printf("SD CARD: %lld bytes\n", (long long) - ivar->csd.capacity); + if (ivar->csd.csd_structure > 0) + ivar->high_cap = 1; + ivar->tran_speed = ivar->csd.tran_speed; + /* Get card SCR. Card must be selected to fetch it. */ + mmc_select_card(sc, ivar->rca); + mmc_app_send_scr(sc, ivar->rca, ivar->raw_scr); + mmc_app_decode_scr(ivar->raw_scr, &ivar->scr); + /* Get card switch capabilities. */ + if ((ivar->scr.sda_vsn >= 1) && + (ivar->csd.ccc & (1<<10))) { + mmc_sd_switch(sc, 0, 0, 0xF, switch_res); + if (switch_res[13] & 2) { + ivar->timing = bus_timing_hs; + ivar->hs_tran_speed = 50000000; + } + } + mmc_select_card(sc, 0); + /* Find max supported bus width. */ + if ((mmcbr_get_caps(sc->dev) & MMC_CAP_4_BIT_DATA) && + (ivar->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) + ivar->bus_width = bus_width_4; + /* Add device. */ child = device_add_child(sc->dev, NULL, -1); device_set_ivars(child, ivar); return; } - panic("Write MMC card code here"); + mmc_decode_cid(0, ivar->raw_cid, &ivar->cid); + ivar->rca = rca++; + mmc_set_relative_addr(sc, ivar->rca); + /* Get card CSD. */ + mmc_send_csd(sc, ivar->rca, ivar->raw_csd); + mmc_decode_csd(0, ivar->raw_csd, &ivar->csd); + ivar->tran_speed = ivar->csd.tran_speed; + /* Only MMC >= 4.x cards support EXT_CSD. */ + if (ivar->csd.spec_vers >= 4) { + /* Card must be selected to fetch EXT_CSD. */ + mmc_select_card(sc, ivar->rca); + mmc_send_ext_csd(sc, ivar->raw_ext_csd); + /* Get card speed in high speed mode. */ + ivar->timing = bus_timing_hs; + if (((uint8_t *)(ivar->raw_ext_csd))[EXT_CSD_CARD_TYPE] + & EXT_CSD_CARD_TYPE_52) + ivar->hs_tran_speed = 52000000; + else if (((uint8_t *)(ivar->raw_ext_csd))[EXT_CSD_CARD_TYPE] + & EXT_CSD_CARD_TYPE_26) + ivar->hs_tran_speed = 26000000; + else + ivar->hs_tran_speed = ivar->tran_speed; + /* Find max supported bus width. */ + ivar->bus_width = mmc_test_bus_width(sc); + mmc_select_card(sc, 0); + } else { + ivar->bus_width = bus_width_1; + ivar->timing = bus_timing_normal; + } + /* Add device. */ + child = device_add_child(sc->dev, NULL, -1); + device_set_ivars(child, ivar); } free(ivar, M_DEVBUF); } @@ -661,6 +1091,7 @@ mmc_go_discovery(struct mmc_softc *sc) { uint32_t ocr; device_t dev; + int err; dev = sc->dev; if (mmcbr_get_power_mode(dev) != power_on) { @@ -671,7 +1102,9 @@ mmc_go_discovery(struct mmc_softc *sc) mmc_power_up(sc); mmcbr_set_bus_mode(dev, pushpull); mmc_idle_cards(sc); - if (mmc_send_app_op_cond(sc, 0, &ocr) != MMC_ERR_NONE) { + err = mmc_send_if_cond(sc, 1); + if (mmc_send_app_op_cond(sc, err?0:MMC_OCR_CCS, &ocr) != + MMC_ERR_NONE) { /* * Failed, try MMC */ @@ -697,9 +1130,11 @@ mmc_go_discovery(struct mmc_softc *sc) /* * Reselect the cards after we've idled them above. */ - if (mmcbr_get_mode(dev) == mode_sd) - mmc_send_app_op_cond(sc, mmcbr_get_ocr(dev), NULL); - else + if (mmcbr_get_mode(dev) == mode_sd) { + err = mmc_send_if_cond(sc, 1); + mmc_send_app_op_cond(sc, + (err?0:MMC_OCR_CCS)|mmcbr_get_ocr(dev), NULL); + } else mmc_send_op_cond(sc, mmcbr_get_ocr(dev), NULL); mmc_discover_cards(sc); @@ -712,22 +1147,47 @@ mmc_go_discovery(struct mmc_softc *sc) static int mmc_calculate_clock(struct mmc_softc *sc) { - int max_dtr = 0; + int max_dtr, max_hs_dtr, max_timing; int nkid, i, f_min, f_max; device_t *kids; + struct mmc_ivars *ivar; f_min = mmcbr_get_f_min(sc->dev); f_max = mmcbr_get_f_max(sc->dev); - max_dtr = f_max; + max_dtr = max_hs_dtr = f_max; + if ((mmcbr_get_caps(sc->dev) & MMC_CAP_HSPEED)) + max_timing = bus_timing_hs; + else + max_timing = bus_timing_normal; if (device_get_children(sc->dev, &kids, &nkid) != 0) panic("can't get children"); - for (i = 0; i < nkid; i++) - if (mmc_get_tran_speed(kids[i]) < max_dtr) - max_dtr = mmc_get_tran_speed(kids[i]); + for (i = 0; i < nkid; i++) { + ivar = device_get_ivars(kids[i]); + if (ivar->timing < max_timing) + max_timing = ivar->timing; + if (ivar->tran_speed < max_dtr) + max_dtr = ivar->tran_speed; + if (ivar->hs_tran_speed < max_dtr) + max_hs_dtr = ivar->hs_tran_speed; + } + for (i = 0; i < nkid; i++) { + ivar = device_get_ivars(kids[i]); + if (ivar->timing == bus_timing_normal) + continue; + mmc_select_card(sc, ivar->rca); + mmc_set_timing(sc, max_timing); + } + mmc_select_card(sc, 0); free(kids, M_TEMP); - device_printf(sc->dev, "setting transfer rate to %d.%03dMHz\n", - max_dtr / 1000000, (max_dtr / 1000) % 1000); - return (max_dtr); + if (max_timing == bus_timing_hs) + max_dtr = max_hs_dtr; + device_printf(sc->dev, "setting transfer rate to %d.%03dMHz%s\n", + max_dtr / 1000000, (max_dtr / 1000) % 1000, + (max_timing == bus_timing_hs)?" with high speed timing":""); + mmcbr_set_timing(sc->dev, max_timing); + mmcbr_set_clock(sc->dev, max_dtr); + mmcbr_update_ios(sc->dev); + return max_dtr; } static void @@ -741,8 +1201,7 @@ mmc_scan(struct mmc_softc *sc) if (mmcbr_get_power_mode(dev) == power_on) mmc_rescan_cards(sc); mmc_go_discovery(sc); - mmcbr_set_clock(dev, mmc_calculate_clock(sc)); - mmcbr_update_ios(dev); + mmc_calculate_clock(sc); mmc_release_bus(dev, dev); /* XXX probe/attach/detach children? */ @@ -774,6 +1233,9 @@ mmc_read_ivar(device_t bus, device_t chi case MMC_IVAR_READ_ONLY: *(int *)result = ivar->read_only; break; + case MMC_IVAR_HIGH_CAP: + *(int *)result = ivar->high_cap; + break; } return (0); } Modified: head/sys/dev/mmc/mmcbrvar.h ============================================================================== --- head/sys/dev/mmc/mmcbrvar.h Wed Oct 8 16:46:36 2008 (r183703) +++ head/sys/dev/mmc/mmcbrvar.h Wed Oct 8 17:35:41 2008 (r183704) @@ -71,6 +71,7 @@ enum mmcbr_device_ivars { MMCBR_IVAR_POWER_MODE, MMCBR_IVAR_VDD, MMCBR_IVAR_CAPS, + MMCBR_IVAR_TIMING, // MMCBR_IVAR_, }; @@ -92,6 +93,7 @@ MMCBR_ACCESSOR(ocr, OCR, int) MMCBR_ACCESSOR(power_mode, POWER_MODE, int) MMCBR_ACCESSOR(vdd, VDD, int) MMCBR_ACCESSOR(caps, CAPS, int) +MMCBR_ACCESSOR(timing, TIMING, int) static int __inline mmcbr_update_ios(device_t dev) Modified: head/sys/dev/mmc/mmcreg.h ============================================================================== --- head/sys/dev/mmc/mmcreg.h Wed Oct 8 16:46:36 2008 (r183703) +++ head/sys/dev/mmc/mmcreg.h Wed Oct 8 17:35:41 2008 (r183704) @@ -86,7 +86,7 @@ struct mmc_command { #define MMC_RSP_R2 (MMC_RSP_PRESENT | MMC_RSP_136 | MMC_RSP_CRC) #define MMC_RSP_R3 (MMC_RSP_PRESENT) #define MMC_RSP_R6 (MMC_RSP_PRESENT | MMC_RSP_CRC) -/* R7 -- new in sd 2.0 */ +#define MMC_RSP_R7 (MMC_RSP_PRESENT | MMC_RSP_CRC) #define MMC_RSP(x) ((x) & MMC_RSP_MASK) uint32_t retries; uint32_t error; @@ -181,16 +181,23 @@ struct mmc_request { #define SD_SEND_RELATIVE_ADDR 3 #define MMC_SET_DSR 4 /* reserved: 5 */ +#define MMC_SWITCH_FUNC 6 +#define MMC_SWITCH_FUNC_CMDS 0 +#define MMC_SWITCH_FUNC_SET 1 +#define MMC_SWITCH_FUNC_CLR 2 +#define MMC_SWITCH_FUNC_WR 3 #define MMC_SELECT_CARD 7 #define MMC_DESELECT_CARD 7 -#define MMC_SEND_IF_COND 8 +#define MMC_SEND_EXT_CSD 8 +#define SD_SEND_IF_COND 8 #define MMC_SEND_CSD 9 #define MMC_SEND_CID 10 #define MMC_READ_DAT_UNTIL_STOP 11 #define MMC_STOP_TRANSMISSION 12 #define MMC_SEND_STATUS 13 - /* reserved: 14 */ +#define MMC_BUSTEST_R 14 #define MMC_GO_INACTIVE_STATE 15 +#define MMC_BUSTEST_W 19 /* Class 2: Block oriented read commands */ #define MMC_SET_BLOCKLEN 16 @@ -277,6 +284,37 @@ struct mmc_request { #define ACMD_SET_CLR_CARD_DETECT 42 #define ACMD_SEND_SCR 51 +/* + * EXT_CSD fields + */ + +#define EXT_CSD_BUS_WIDTH 183 /* R/W */ +#define EXT_CSD_HS_TIMING 185 /* R/W */ +#define EXT_CSD_CARD_TYPE 196 /* RO */ +#define EXT_CSD_REV 192 /* RO */ +#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ + +/* + * EXT_CSD field definitions + */ + +#define EXT_CSD_CMD_SET_NORMAL 1 +#define EXT_CSD_CMD_SET_SECURE 2 +#define EXT_CSD_CMD_SET_CPSECURE 4 + +#define EXT_CSD_CARD_TYPE_26 1 +#define EXT_CSD_CARD_TYPE_52 2 + +#define EXT_CSD_BUS_WIDTH_1 0 +#define EXT_CSD_BUS_WIDTH_4 1 +#define EXT_CSD_BUS_WIDTH_8 2 + +/* + * SD bus widths + */ +#define SD_BUS_WIDTH_1 0 +#define SD_BUS_WIDTH_4 2 + /* OCR bits */ /* @@ -328,6 +366,7 @@ struct mmc_cid { struct mmc_csd { uint8_t csd_structure; + uint8_t spec_vers; uint16_t ccc; uint16_t tacc; uint32_t nsac; @@ -351,6 +390,14 @@ struct mmc_csd wp_grp_enable:1; }; +struct mmc_scr +{ + unsigned char sda_vsn; + unsigned char bus_widths; +#define SD_SCR_BUS_WIDTH_1 (1<<0) +#define SD_SCR_BUS_WIDTH_4 (1<<2) +}; + /* * Older versions of the MMC standard had a variable sector size. However, * I've been able to find no old MMC or SD cards that have a non 512 Modified: head/sys/dev/mmc/mmcsd.c ============================================================================== --- head/sys/dev/mmc/mmcsd.c Wed Oct 8 16:46:36 2008 (r183703) +++ head/sys/dev/mmc/mmcsd.c Wed Oct 8 17:35:41 2008 (r183704) @@ -106,6 +106,7 @@ static int mmcsd_probe(device_t dev) { + device_quiet(dev); device_set_desc(dev, "MMC/SD Memory Card"); return (0); } @@ -256,7 +257,9 @@ mmcsd_task(void *arg) else cmd.opcode = MMC_WRITE_BLOCK; } - cmd.arg = block << 9; + cmd.arg = block; + if (!mmc_get_high_cap(dev)) + cmd.arg <<= 9; cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; data.data = vaddr; data.mrq = &req; Modified: head/sys/dev/mmc/mmcvar.h ============================================================================== --- head/sys/dev/mmc/mmcvar.h Wed Oct 8 16:46:36 2008 (r183703) +++ head/sys/dev/mmc/mmcvar.h Wed Oct 8 17:35:41 2008 (r183704) @@ -62,6 +62,7 @@ enum mmc_device_ivars { MMC_IVAR_SECTOR_SIZE, MMC_IVAR_TRAN_SPEED, MMC_IVAR_READ_ONLY, + MMC_IVAR_HIGH_CAP, // MMC_IVAR_, }; @@ -77,5 +78,6 @@ MMC_ACCESSOR(rca, RCA, int) MMC_ACCESSOR(sector_size, SECTOR_SIZE, int) MMC_ACCESSOR(tran_speed, TRAN_SPEED, int) MMC_ACCESSOR(read_only, READ_ONLY, int) +MMC_ACCESSOR(high_cap, HIGH_CAP, int) #endif /* DEV_MMC_MMCVAR_H */ From mav at FreeBSD.org Wed Oct 8 18:13:14 2008 From: mav at FreeBSD.org (Alexander Motin) Date: Wed Oct 8 18:13:20 2008 Subject: svn commit: r183705 - head/sys/dev/mmc Message-ID: <200810081813.m98IDECv040219@svn.freebsd.org> Author: mav Date: Wed Oct 8 18:13:14 2008 New Revision: 183705 URL: http://svn.freebsd.org/changeset/base/183705 Log: Fix bit offset in mmc_sd_switch(). Modified: head/sys/dev/mmc/mmc.c Modified: head/sys/dev/mmc/mmc.c ============================================================================== --- head/sys/dev/mmc/mmc.c Wed Oct 8 17:35:41 2008 (r183704) +++ head/sys/dev/mmc/mmc.c Wed Oct 8 18:13:14 2008 (r183705) @@ -555,8 +555,8 @@ mmc_sd_switch(struct mmc_softc *sc, uint cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC; cmd.arg = mode << 31; cmd.arg |= 0x00FFFFFF; - cmd.arg &= ~(0xF << grp); - cmd.arg |= value << grp; + cmd.arg &= ~(0xF << (grp * 4)); + cmd.arg |= value << (grp * 4); cmd.data = &data; data.data = res; From mav at FreeBSD.org Wed Oct 8 18:27:54 2008 From: mav at FreeBSD.org (Alexander Motin) Date: Wed Oct 8 18:28:05 2008 Subject: svn commit: r183706 - head/share/man/man4 Message-ID: <200810081827.m98IRseU040492@svn.freebsd.org> Author: mav Date: Wed Oct 8 18:27:54 2008 New Revision: 183706 URL: http://svn.freebsd.org/changeset/base/183706 Log: Remove stale BUGS. Modified: head/share/man/man4/mmc.4 Modified: head/share/man/man4/mmc.4 ============================================================================== --- head/share/man/man4/mmc.4 Wed Oct 8 18:13:14 2008 (r183705) +++ head/share/man/man4/mmc.4 Wed Oct 8 18:27:54 2008 (r183706) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 26, 2007 +.Dd October 8, 2008 .Dt MMC 4 .Os .Sh NAME @@ -56,6 +56,4 @@ SD Cards exist as memory, I/O, or combin .%T "The MultiMediaCard System Specification" .Re .Sh BUGS -Memory MultMediaCards do not currently work. SDIO cards currently do not work. -SDHC cards currently do not work. From phk at FreeBSD.org Wed Oct 8 19:39:24 2008 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed Oct 8 19:39:35 2008 Subject: svn commit: r183707 - head/games/fortune/datfiles Message-ID: <200810081939.m98JdMf4041744@svn.freebsd.org> Author: phk Date: Wed Oct 8 19:39:22 2008 New Revision: 183707 URL: http://svn.freebsd.org/changeset/base/183707 Log: Another good day for historical quotes, Oliver Wendell Holmes brought to you by Thomas L. Friedman. (http://www.nytimes.com/2008/10/08/opinion/08friedman.html?ref=opinion) Modified: head/games/fortune/datfiles/fortunes Modified: head/games/fortune/datfiles/fortunes ============================================================================== --- head/games/fortune/datfiles/fortunes Wed Oct 8 18:27:54 2008 (r183706) +++ head/games/fortune/datfiles/fortunes Wed Oct 8 19:39:22 2008 (r183707) @@ -23951,6 +23951,9 @@ I like myself, but I won't say I'm as ha that kidnaped Europa. -- Marcus Tullius Cicero % +I like paying taxes. With them I buy civilization. + -- Oliver Wendell Holmes +% I like to believe that people in the long run are going to do more to promote peace than our governments. Indeed, I think that people want peace so much that one of these days governments had better get out of From mav at FreeBSD.org Wed Oct 8 20:00:52 2008 From: mav at FreeBSD.org (Alexander Motin) Date: Wed Oct 8 20:00:58 2008 Subject: svn commit: r183708 - head/sys/dev/mmc Message-ID: <200810082000.m98K0pQi042156@svn.freebsd.org> Author: mav Date: Wed Oct 8 20:00:51 2008 New Revision: 183708 URL: http://svn.freebsd.org/changeset/base/183708 Log: Generic SD Host Controller driver going to be named sdhci. Modified: head/sys/dev/mmc/mmc.c Modified: head/sys/dev/mmc/mmc.c ============================================================================== --- head/sys/dev/mmc/mmc.c Wed Oct 8 19:39:22 2008 (r183707) +++ head/sys/dev/mmc/mmc.c Wed Oct 8 20:00:51 2008 (r183708) @@ -1286,4 +1286,4 @@ static devclass_t mmc_devclass; DRIVER_MODULE(mmc, at91_mci, mmc_driver, mmc_devclass, 0, 0); -DRIVER_MODULE(mmc, sdh, mmc_driver, mmc_devclass, 0, 0); +DRIVER_MODULE(mmc, sdhci, mmc_driver, mmc_devclass, 0, 0); From mav at FreeBSD.org Wed Oct 8 21:10:55 2008 From: mav at FreeBSD.org (Alexander Motin) Date: Wed Oct 8 21:11:07 2008 Subject: svn commit: r183709 - head/sys/dev/mmc Message-ID: <200810082110.m98LAttm043368@svn.freebsd.org> Author: mav Date: Wed Oct 8 21:10:55 2008 New Revision: 183709 URL: http://svn.freebsd.org/changeset/base/183709 Log: Only voltage bits should be zero in send_op_cond argument to ignore busy. Modified: head/sys/dev/mmc/mmc.c Modified: head/sys/dev/mmc/mmc.c ============================================================================== --- head/sys/dev/mmc/mmc.c Wed Oct 8 20:00:51 2008 (r183708) +++ head/sys/dev/mmc/mmc.c Wed Oct 8 21:10:55 2008 (r183709) @@ -428,7 +428,8 @@ mmc_send_app_op_cond(struct mmc_softc *s err = mmc_wait_for_app_cmd(sc, 0, &cmd, CMD_RETRIES); if (err != MMC_ERR_NONE) break; - if ((cmd.resp[0] & MMC_OCR_CARD_BUSY) || ocr == 0) + if ((cmd.resp[0] & MMC_OCR_CARD_BUSY) || + (ocr & MMC_OCR_VOLTAGE) == 0) break; err = MMC_ERR_TIMEOUT; mmc_ms_delay(10); @@ -454,7 +455,8 @@ mmc_send_op_cond(struct mmc_softc *sc, u err = mmc_wait_for_cmd(sc, &cmd, CMD_RETRIES); if (err != MMC_ERR_NONE) break; - if ((cmd.resp[0] & MMC_OCR_CARD_BUSY) || ocr == 0) + if ((cmd.resp[0] & MMC_OCR_CARD_BUSY) || + (ocr & MMC_OCR_VOLTAGE) == 0) break; err = MMC_ERR_TIMEOUT; mmc_ms_delay(10); From peter at FreeBSD.org Thu Oct 9 02:25:18 2008 From: peter at FreeBSD.org (Peter Wemm) Date: Thu Oct 9 02:25:25 2008 Subject: svn commit: r183714 - in head: etc/rc.d lib/libarchive lib/libc/stdlib lib/msun/src share/man/man4 sys/dev/e1000 sys/dev/iicbus sys/dev/pcn sys/dev/sis sys/dev/ste sys/dev/tl sys/dev/wb sys/dev/xl ... Message-ID: <200810090225.m992PIom049355@svn.freebsd.org> Author: peter Date: Thu Oct 9 02:25:18 2008 New Revision: 183714 URL: http://svn.freebsd.org/changeset/base/183714 Log: Clean out some empty mergeinfo records, presumably by people doing local cp/mv operations. The full repo-relative URL should be specified for the source in these cases. Modified: head/etc/rc.d/defaultroute (props changed) head/lib/libarchive/archive.h (props changed) head/lib/libc/stdlib/ptsname.3 (props changed) head/lib/msun/src/s_cargl.c (props changed) head/share/man/man4/igb.4 (props changed) head/sys/dev/e1000/ (props changed) head/sys/dev/e1000/e1000_82575.c (props changed) head/sys/dev/e1000/e1000_82575.h (props changed) head/sys/dev/e1000/if_igb.c (props changed) head/sys/dev/e1000/if_igb.h (props changed) head/sys/dev/iicbus/ds133x.c (props changed) head/sys/dev/pcn/if_pcn.c (props changed) head/sys/dev/pcn/if_pcnreg.h (props changed) head/sys/dev/sis/if_sis.c (props changed) head/sys/dev/sis/if_sisreg.h (props changed) head/sys/dev/ste/if_ste.c (props changed) head/sys/dev/ste/if_stereg.h (props changed) head/sys/dev/tl/if_tl.c (props changed) head/sys/dev/tl/if_tlreg.h (props changed) head/sys/dev/wb/if_wb.c (props changed) head/sys/dev/wb/if_wbreg.h (props changed) head/sys/dev/xl/if_xl.c (props changed) head/sys/dev/xl/if_xlreg.h (props changed) head/sys/mips/adm5120/ (props changed) head/sys/mips/idt/ (props changed) head/sys/mips/malta/ (props changed) head/sys/mips/sentry5/ (props changed) From jkoshy at FreeBSD.org Thu Oct 9 06:19:43 2008 From: jkoshy at FreeBSD.org (Joseph Koshy) Date: Thu Oct 9 06:19:55 2008 Subject: svn commit: r183717 - head/sys/dev/hwpmc Message-ID: <200810090619.m996JgOK053813@svn.freebsd.org> Author: jkoshy Date: Thu Oct 9 06:19:42 2008 New Revision: 183717 URL: http://svn.freebsd.org/changeset/base/183717 Log: Rework pmc-dependent flag handling. Modified: head/sys/dev/hwpmc/hwpmc_ppro.c Modified: head/sys/dev/hwpmc/hwpmc_ppro.c ============================================================================== --- head/sys/dev/hwpmc/hwpmc_ppro.c Thu Oct 9 05:11:27 2008 (r183716) +++ head/sys/dev/hwpmc/hwpmc_ppro.c Thu Oct 9 06:19:42 2008 (r183717) @@ -121,6 +121,11 @@ static enum pmc_cputype p6_cputype; /* * P6 Event descriptor + * + * The 'pm_flags' field has the following structure: + * - The upper 4 bits are used to track which counter an event is valid on. + * - The lower bits form a bitmask of flags indicating support for the event + * on a given CPU. */ struct p6_event_descr { @@ -130,6 +135,23 @@ struct p6_event_descr { uint32_t pm_unitmask; }; +#define P6F_CTR(C) (1 << (28 + (C))) +#define P6F_CTR0 P6F_CTR(0) +#define P6F_CTR1 P6F_CTR(1) +#define P6F(CPU) (1 << ((CPU) - PMC_CPU_INTEL_P6)) +#define _P6F(C) P6F(PMC_CPU_INTEL_##C) +#define P6F_P6 _P6F(P6) +#define P6F_CL _P6F(CL) +#define P6F_PII _P6F(PII) +#define P6F_PIII _P6F(PIII) +#define P6F_PM _P6F(PM) +#define P6F_ALL_CPUS (P6F_P6 | P6F_PII | P6F_CL | P6F_PIII | P6F_PM) +#define P6F_ALL_CTRS (P6F_CTR0 | P6F_CTR1) +#define P6F_ALL (P6F_ALL_CPUS | P6F_ALL_CTRS) + +#define P6_EVENT_VALID_FOR_CPU(P,CPU) ((P)->pm_flags & P6F(CPU)) +#define P6_EVENT_VALID_FOR_CTR(P,CTR) ((P)->pm_flags & P6F_CTR(CTR)) + static const struct p6_event_descr p6_events[] = { #define P6_EVDESCR(NAME, EVSEL, FLAGS, UMASK) \ @@ -140,20 +162,6 @@ static const struct p6_event_descr p6_ev .pm_unitmask = (UMASK) \ } -#define P6F_P6 (1 << PMC_CPU_INTEL_P6) -#define P6F_CL (1 << PMC_CPU_INTEL_CL) -#define P6F_PII (1 << PMC_CPU_INTEL_PII) -#define P6F_PIII (1 << PMC_CPU_INTEL_PIII) -#define P6F_PM (1 << PMC_CPU_INTEL_PM) -#define P6F_CTR0 0x0001 -#define P6F_CTR1 0x0002 -#define P6F_ALL_CPUS (P6F_P6 | P6F_PII | P6F_CL | P6F_PIII | P6F_PM) -#define P6F_ALL_CTRS (P6F_CTR0 | P6F_CTR1) -#define P6F_ALL (P6F_ALL_CPUS | P6F_ALL_CTRS) - -#define P6_EVENT_VALID_FOR_CPU(P,CPU) ((P)->pm_flags & (1 << (CPU))) -#define P6_EVENT_VALID_FOR_CTR(P,CTR) ((P)->pm_flags & (1 << (CTR))) - P6_EVDESCR(DATA_MEM_REFS, 0x43, P6F_ALL, 0x00), P6_EVDESCR(DCU_LINES_IN, 0x45, P6F_ALL, 0x00), P6_EVDESCR(DCU_M_LINES_IN, 0x46, P6F_ALL, 0x00), From delphij at FreeBSD.org Thu Oct 9 06:23:04 2008 From: delphij at FreeBSD.org (Xin LI) Date: Thu Oct 9 06:23:10 2008 Subject: svn commit: r183718 - head/sbin/geom/class/part Message-ID: <200810090623.m996N4XJ053923@svn.freebsd.org> Author: delphij Date: Thu Oct 9 06:23:04 2008 New Revision: 183718 URL: http://svn.freebsd.org/changeset/base/183718 Log: Add some examples to demostrate gpart(8). --????????????-- > Description of fields to fill in above: 76 columns --| > PR: If a GNATS PR is affected by the change. > Submitted by: If someone else sent in the change. > Reviewed by: If someone else reviewed your modification. > Approved by: If you needed approval for this commit. > Obtained from: If the change is from a third party. > MFC after: N [day[s]|week[s]|month[s]]. Request a reminder email. > Security: Vulnerability reference (one per line) or description. > Empty fields above will be automatically removed. M gpart.8 Modified: head/sbin/geom/class/part/gpart.8 Modified: head/sbin/geom/class/part/gpart.8 ============================================================================== --- head/sbin/geom/class/part/gpart.8 Thu Oct 9 06:19:42 2008 (r183717) +++ head/sbin/geom/class/part/gpart.8 Thu Oct 9 06:23:04 2008 (r183718) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd Jun 17, 2008 +.Dd Oct 9, 2008 .Dt GPART 8 .Os .Sh NAME @@ -404,6 +404,41 @@ action or reverted with the action. .Sh EXIT STATUS Exit status is 0 on success, and 1 if the command fails. +.Sh EXAMPLES +Create GPT scheme on +.Pa ad0 . +.Bd -literal -offset indent +/sbin/gpart create -s GPT ad0 +.Ed +.Pp +Embed GPT bootstrap code into protective MBR. +.Bd -literal -offset indent +/sbin/gpart bootcode -b /boot/pmbr ad0 +.Ed +.Pp +Create a dedicated +.Pa freebsd-boot +partition that can boot FreeBSD from a +.Pa freebsd-ufs +partition, and install bootstrap code into it. +This partition must be larger than +.Pa /boot/gptboot , +or the GPT boot you are willing to write, +a size of 15 blocks (7680 bytes) would be sufficient for +booting from UFS, but let's use 128 blocks (64 KB) here in +this example, in order to reserve some space for potential +future need (e.g. from a ZFS partition). +.Bd -literal -offset indent +/sbin/gpart add -b 34 -s 128 -t freebsd-boot ad0 +/sbin/gpart bootcode -p /boot/gptboot -i 1 ad0 +.Ed +.Pp +Create a 512MB-sized +.Pa freebsd-ufs +partition that would contain UFS where the system boot from. +.Bd -literal -offset indent +/sbin/gpart add -b 162 -s 1048576 -t freebsd-ufs ad0 +.Ed .Sh SEE ALSO .Xr geom 4 , .Xr geom 8 , From delphij at delphij.net Thu Oct 9 06:38:50 2008 From: delphij at delphij.net (Xin LI) Date: Thu Oct 9 06:39:02 2008 Subject: svn commit: r183718 - head/sbin/geom/class/part In-Reply-To: References: <200810090623.m996N4XJ053923@svn.freebsd.org> Message-ID: <48EDA6EC.6060205@delphij.net> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Peter Wemm wrote: > On Wed, Oct 8, 2008 at 11:23 PM, Xin LI wrote: >> Author: delphij >> Date: Thu Oct 9 06:23:04 2008 >> New Revision: 183718 >> URL: http://svn.freebsd.org/changeset/base/183718 >> >> Log: >> Add some examples to demostrate gpart(8). >> --????????????-- >> > Description of fields to fill in above: 76 columns --| >> > PR: If a GNATS PR is affected by the change. >> > Submitted by: If someone else sent in the change. >> > Reviewed by: If someone else reviewed your modification. >> > Approved by: If you needed approval for this commit. >> > Obtained from: If the change is from a third party. >> > MFC after: N [day[s]|week[s]|month[s]]. Request a reminder email. >> > Security: Vulnerability reference (one per line) or description. >> > Empty fields above will be automatically removed. >> >> M gpart.8 > > Looks like the hack that removes the template doesn't work when svn > has its localizations enabled. Oops. I'll get this fixed for the > svn-1.5.3 update, which is in the process of being released. > > In the mean time, you'll have to delete them by hand before commit. Sorry. :( Oops, sorry for that. Is it still possible to trim it by editing svn:log property? Cheers, -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) iEYEARECAAYFAkjtpusACgkQi+vbBBjt66A0DwCffOMlF0vC18s7KKyG18gr/7cl MMEAn2OqA8NhCK1DihCwpz+839BfW7B4 =YUxX -----END PGP SIGNATURE----- From peter at wemm.org Thu Oct 9 06:55:50 2008 From: peter at wemm.org (Peter Wemm) Date: Thu Oct 9 06:55:56 2008 Subject: svn commit: r183718 - head/sbin/geom/class/part In-Reply-To: <200810090623.m996N4XJ053923@svn.freebsd.org> References: <200810090623.m996N4XJ053923@svn.freebsd.org> Message-ID: On Wed, Oct 8, 2008 at 11:23 PM, Xin LI wrote: > Author: delphij > Date: Thu Oct 9 06:23:04 2008 > New Revision: 183718 > URL: http://svn.freebsd.org/changeset/base/183718 > > Log: > Add some examples to demostrate gpart(8). > --????????????-- > > Description of fields to fill in above: 76 columns --| > > PR: If a GNATS PR is affected by the change. > > Submitted by: If someone else sent in the change. > > Reviewed by: If someone else reviewed your modification. > > Approved by: If you needed approval for this commit. > > Obtained from: If the change is from a third party. > > MFC after: N [day[s]|week[s]|month[s]]. Request a reminder email. > > Security: Vulnerability reference (one per line) or description. > > Empty fields above will be automatically removed. > > M gpart.8 Looks like the hack that removes the template doesn't work when svn has its localizations enabled. Oops. I'll get this fixed for the svn-1.5.3 update, which is in the process of being released. In the mean time, you'll have to delete them by hand before commit. Sorry. :( -- Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com; KI6FJV "All of this is for nothing if we don't go to the stars" - JMS/B5 "If Java had true garbage collection, most programs would delete themselves upon execution." -- Robert Sewell From olli at fromme.com Thu Oct 9 08:12:46 2008 From: olli at fromme.com (Oliver Fromme) Date: Thu Oct 9 08:12:52 2008 Subject: svn commit: r183718 - head/sbin/geom/class/part In-Reply-To: Message-ID: <200810090754.m997sDwv086411@haluter.fromme.com> Peter Wemm wrote: > On Wed, Oct 8, 2008 at 11:23 PM, Xin LI wrote: > > Author: delphij > > Date: Thu Oct 9 06:23:04 2008 > > New Revision: 183718 > > URL: http://svn.freebsd.org/changeset/base/183718 > > > > Log: > > Add some examples to demostrate gpart(8). > > --$B:!9T5Z0J2-2qHo9zN,(B-- > > > Description of fields to fill in above: 76 columns --| > > > PR: If a GNATS PR is affected by the change. > > > Submitted by: If someone else sent in the change. > > > Reviewed by: If someone else reviewed your modification. > > > Approved by: If you needed approval for this commit. > > > Obtained from: If the change is from a third party. > > > MFC after: N [day[s]|week[s]|month[s]]. Request a reminder email. > > > Security: Vulnerability reference (one per line) or description. > > > Empty fields above will be automatically removed. > > > > M gpart.8 > > Looks like the hack that removes the template doesn't work when svn > has its localizations enabled. Oops. I'll get this fixed for the > svn-1.5.3 update, which is in the process of being released. This commit also revealed a bug in my "SVNews" tool; it didn't support UTF-8 charactes correctly that can't be mapped to ISO8859-*. Now it does. So I'm thankful for delphij's commit message because it gave me the opportunity to discover and fix the bug. :-) Best regards Oliver PS: Ivan: I decided to implement displaying diffs, as you suggested. Working on it right now. It only stores the most recent diffs (currently 10 days). -- Oliver Fromme, Bunsenstr. 13, 81735 Muenchen, Germany ``We are all but compressed light'' (Albert Einstein) From ivoras at gmail.com Thu Oct 9 10:04:43 2008 From: ivoras at gmail.com (Ivan Voras) Date: Thu Oct 9 10:04:50 2008 Subject: svn commit: r183718 - head/sbin/geom/class/part In-Reply-To: <200810090754.m997sDwv086411@haluter.fromme.com> References: <200810090754.m997sDwv086411@haluter.fromme.com> Message-ID: <9bbcef730810090238y8d8eb3fl200fd25371e4d69b@mail.gmail.com> 2008/10/9 Oliver Fromme : > PS: Ivan: I decided to implement displaying diffs, > as you suggested. Working on it right now. It only > stores the most recent diffs (currently 10 days). Thanks, this will be completely sufficient for RSS! From sos at FreeBSD.org Thu Oct 9 12:56:57 2008 From: sos at FreeBSD.org (Søren Schmidt) Date: Thu Oct 9 12:57:05 2008 Subject: svn commit: r183724 - in head/sys: conf dev/ata dev/ata/chipsets modules/ata modules/ata/ata modules/ata/atacore modules/ata/atadevel modules/ata/atapci modules/ata/atapci/chipsets modules/ata/atap... Message-ID: <200810091256.m99Cuvex062502@svn.freebsd.org> Author: sos Date: Thu Oct 9 12:56:57 2008 New Revision: 183724 URL: http://svn.freebsd.org/changeset/base/183724 Log: This is the roumored ATA modulerisation works, and it needs a little explanation. If you just config KERNEL as usual there should be no apparent changes, you'll get all chipset support code compiled in. However there is now a way to only compile in code for chipsets needed on a pr vendor basis. ATA now has the following "device" entries: atacore: ATA core functionality, always needed for any ATA setup atacard: CARDBUS support atacbus: PC98 cbus support ataisa: ISA bus support atapci: PCI bus support only generic chipset support. ataahci: AHCI support, also pulled in by some vendor modules. ataacard, ataacerlabs, ataadaptec, ataamd, ataati, atacenatek, atacypress, atacyrix, atahighpoint, ataintel, ataite, atajmicron, atamarvell, atamicron, atanational, atanetcell, atanvidia, atapromise, ataserverworks, atasiliconimage, atasis, atavia; Vendor support, ie atavia for VIA chipsets atadisk: ATA disk driver ataraid: ATA softraid driver atapicd: ATAPI cd/dvd driver atapifd: ATAPI floppy/flashdisk driver atapist: ATAPI tape driver atausb: ATA<>USB bridge atapicam: ATA<>CAM bridge This makes it possible to config a kernel with just VIA chipset support by having the following ATA lines in the kernel config file: device atacore device atapci device atavia And then you need the atadisk, atapicd etc lines in there just as usual. If you use ATA as modules loaded at boot there is few changes except the rename of the "ata" module to "atacore", things looks just as usual. However under atapci you now have a whole bunch of vendor specific drivers, that you can kldload individually depending on you needs. Drivers have the same names as used in the kernel config explained above. Added: head/sys/dev/ata/ata-sata.c (contents, props changed) head/sys/dev/ata/chipsets/ head/sys/dev/ata/chipsets/ata-acard.c (contents, props changed) head/sys/dev/ata/chipsets/ata-acerlabs.c (contents, props changed) head/sys/dev/ata/chipsets/ata-adaptec.c (contents, props changed) head/sys/dev/ata/chipsets/ata-ahci.c (contents, props changed) head/sys/dev/ata/chipsets/ata-amd.c (contents, props changed) head/sys/dev/ata/chipsets/ata-ati.c (contents, props changed) head/sys/dev/ata/chipsets/ata-cenatek.c (contents, props changed) head/sys/dev/ata/chipsets/ata-cypress.c (contents, props changed) head/sys/dev/ata/chipsets/ata-cyrix.c (contents, props changed) head/sys/dev/ata/chipsets/ata-highpoint.c (contents, props changed) head/sys/dev/ata/chipsets/ata-intel.c (contents, props changed) head/sys/dev/ata/chipsets/ata-ite.c (contents, props changed) head/sys/dev/ata/chipsets/ata-jmicron.c (contents, props changed) head/sys/dev/ata/chipsets/ata-marvell.c (contents, props changed) head/sys/dev/ata/chipsets/ata-micron.c (contents, props changed) head/sys/dev/ata/chipsets/ata-national.c (contents, props changed) head/sys/dev/ata/chipsets/ata-netcell.c (contents, props changed) head/sys/dev/ata/chipsets/ata-nvidia.c (contents, props changed) head/sys/dev/ata/chipsets/ata-promise.c (contents, props changed) head/sys/dev/ata/chipsets/ata-serverworks.c (contents, props changed) head/sys/dev/ata/chipsets/ata-siliconimage.c (contents, props changed) head/sys/dev/ata/chipsets/ata-sis.c (contents, props changed) head/sys/dev/ata/chipsets/ata-via.c (contents, props changed) head/sys/modules/ata/atacore/ head/sys/modules/ata/atacore/Makefile (contents, props changed) head/sys/modules/ata/atadevel/ head/sys/modules/ata/atadevel/Makefile (contents, props changed) head/sys/modules/ata/atadevel/ata-devel.c (contents, props changed) head/sys/modules/ata/atapci/Makefile.inc (contents, props changed) head/sys/modules/ata/atapci/chipsets/ head/sys/modules/ata/atapci/chipsets/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/Makefile.inc (contents, props changed) head/sys/modules/ata/atapci/chipsets/ataacard/ head/sys/modules/ata/atapci/chipsets/ataacard/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/ataacerlabs/ head/sys/modules/ata/atapci/chipsets/ataacerlabs/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/ataadaptec/ head/sys/modules/ata/atapci/chipsets/ataadaptec/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/ataahci/ head/sys/modules/ata/atapci/chipsets/ataahci/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/ataamd/ head/sys/modules/ata/atapci/chipsets/ataamd/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/ataati/ head/sys/modules/ata/atapci/chipsets/ataati/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/atacenatek/ head/sys/modules/ata/atapci/chipsets/atacenatek/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/atacypress/ head/sys/modules/ata/atapci/chipsets/atacypress/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/atacyrix/ head/sys/modules/ata/atapci/chipsets/atacyrix/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/atahighpoint/ head/sys/modules/ata/atapci/chipsets/atahighpoint/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/ataintel/ head/sys/modules/ata/atapci/chipsets/ataintel/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/ataite/ head/sys/modules/ata/atapci/chipsets/ataite/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/atajmicron/ head/sys/modules/ata/atapci/chipsets/atajmicron/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/atamarvell/ head/sys/modules/ata/atapci/chipsets/atamarvell/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/atamicron/ head/sys/modules/ata/atapci/chipsets/atamicron/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/atanational/ head/sys/modules/ata/atapci/chipsets/atanational/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/atanetcell/ head/sys/modules/ata/atapci/chipsets/atanetcell/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/atanvidia/ head/sys/modules/ata/atapci/chipsets/atanvidia/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/atapromise/ head/sys/modules/ata/atapci/chipsets/atapromise/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/ataserverworks/ head/sys/modules/ata/atapci/chipsets/ataserverworks/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/atasiliconimage/ head/sys/modules/ata/atapci/chipsets/atasiliconimage/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/atasis/ head/sys/modules/ata/atapci/chipsets/atasis/Makefile (contents, props changed) head/sys/modules/ata/atapci/chipsets/atavia/ head/sys/modules/ata/atapci/chipsets/atavia/Makefile (contents, props changed) Deleted: head/sys/dev/ata/ata-chipset.c head/sys/modules/ata/ata/Makefile Modified: head/sys/conf/files head/sys/dev/ata/ata-all.c head/sys/dev/ata/ata-all.h head/sys/dev/ata/ata-dma.c head/sys/dev/ata/ata-pci.c head/sys/dev/ata/ata-pci.h head/sys/modules/ata/Makefile head/sys/modules/ata/atapci/Makefile Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Thu Oct 9 12:25:07 2008 (r183723) +++ head/sys/conf/files Thu Oct 9 12:56:57 2008 (r183724) @@ -459,23 +459,49 @@ dev/an/if_an_isa.c optional an isa dev/an/if_an_pccard.c optional an pccard dev/an/if_an_pci.c optional an pci dev/asr/asr.c optional asr pci -dev/ata/ata_if.m optional ata -dev/ata/ata-all.c optional ata -dev/ata/ata-card.c optional ata pccard -dev/ata/ata-cbus.c optional ata pc98 -dev/ata/ata-chipset.c optional ata pci +# +dev/ata/ata_if.m optional ata | atacore +dev/ata/ata-all.c optional ata | atacore +dev/ata/ata-lowlevel.c optional ata | atacore +dev/ata/ata-queue.c optional ata | atacore +dev/ata/ata-card.c optional ata pccard | atapccard +dev/ata/ata-cbus.c optional ata pc98 | atapc98 +dev/ata/ata-isa.c optional ata isa | ataisa +dev/ata/ata-pci.c optional ata pci | atapci +dev/ata/ata-dma.c optional ata pci | atapci +dev/ata/ata-sata.c optional ata pci | atapci +dev/ata/chipsets/ata-ahci.c optional ata pci | ataahci | ataacerlabs | \ + ataati | ataintel | atajmicron | atavia +dev/ata/chipsets/ata-acard.c optional ata pci | ataacard +dev/ata/chipsets/ata-acerlabs.c optional ata pci | ataacerlabs +dev/ata/chipsets/ata-adaptec.c optional ata pci | ataadaptec +dev/ata/chipsets/ata-amd.c optional ata pci | ataamd +dev/ata/chipsets/ata-ati.c optional ata pci | ataati +dev/ata/chipsets/ata-cenatek.c optional ata pci | atacenatek +dev/ata/chipsets/ata-cypress.c optional ata pci | atacypress +dev/ata/chipsets/ata-cyrix.c optional ata pci | atacyrix +dev/ata/chipsets/ata-highpoint.c optional ata pci | atahighpoint +dev/ata/chipsets/ata-intel.c optional ata pci | ataintel +dev/ata/chipsets/ata-ite.c optional ata pci | ataite +dev/ata/chipsets/ata-jmicron.c optional ata pci | atajmicron +dev/ata/chipsets/ata-marvell.c optional ata pci | atamarvell +dev/ata/chipsets/ata-micron.c optional ata pci | atamicron +dev/ata/chipsets/ata-national.c optional ata pci | atanational +dev/ata/chipsets/ata-netcell.c optional ata pci | atanetcell +dev/ata/chipsets/ata-nvidia.c optional ata pci | atanvidia +dev/ata/chipsets/ata-promise.c optional ata pci | atapromise +dev/ata/chipsets/ata-serverworks.c optional ata pci | ataserverworks +dev/ata/chipsets/ata-siliconimage.c optional ata pci | atasiliconimage +dev/ata/chipsets/ata-sis.c optional ata pci | atasis +dev/ata/chipsets/ata-via.c optional ata pci | atavia dev/ata/ata-disk.c optional atadisk -dev/ata/ata-dma.c optional ata pci -dev/ata/ata-isa.c optional ata isa -dev/ata/ata-lowlevel.c optional ata -dev/ata/ata-pci.c optional ata pci -dev/ata/ata-queue.c optional ata dev/ata/ata-raid.c optional ataraid dev/ata/ata-usb.c optional atausb -dev/ata/atapi-cam.c optional atapicam dev/ata/atapi-cd.c optional atapicd dev/ata/atapi-fd.c optional atapifd dev/ata/atapi-tape.c optional atapist +dev/ata/atapi-cam.c optional atapicam +# dev/ath/ah_osdep.c optional ath_hal \ compile-with "${NORMAL_C} -I$S/dev/ath" dev/ath/ath_rate/amrr/amrr.c optional ath_rate_amrr \ Modified: head/sys/dev/ata/ata-all.c ============================================================================== --- head/sys/dev/ata/ata-all.c Thu Oct 9 12:25:07 2008 (r183723) +++ head/sys/dev/ata/ata-all.c Thu Oct 9 12:56:57 2008 (r183724) @@ -616,7 +616,6 @@ ata_getparam(struct ata_device *atadev, if (!error && (isprint(atadev->param.model[0]) || isprint(atadev->param.model[1]))) { struct ata_params *atacap = &atadev->param; - char buffer[64]; int16_t *ptr; for (ptr = (int16_t *)atacap; @@ -648,6 +647,8 @@ ata_getparam(struct ata_device *atadev, (atacap->hwres & ATA_CABLE_ID) ? "80":"40"); if (init) { + char buffer[64]; + sprintf(buffer, "%.40s/%.8s", atacap->model, atacap->revision); device_set_desc_copy(atadev->dev, buffer); if ((atadev->param.config & ATA_PROTO_ATAPI) && @@ -677,8 +678,8 @@ int ata_identify(device_t dev) { struct ata_channel *ch = device_get_softc(dev); - struct ata_device *devices[ATA_PM]; - device_t childdevs[ATA_PM]; + struct ata_device *atadev; + device_t child; int i; if (bootverbose) @@ -688,33 +689,26 @@ ata_identify(device_t dev) if (ch->devices & (((ATA_ATA_MASTER | ATA_ATAPI_MASTER) << i))) { int unit = -1; - if (!(devices[i] = malloc(sizeof(struct ata_device), - M_ATA, M_NOWAIT | M_ZERO))) { + if (!(atadev = malloc(sizeof(struct ata_device), + M_ATA, M_NOWAIT | M_ZERO))) { device_printf(dev, "out of memory\n"); return ENOMEM; } - devices[i]->unit = i; + atadev->unit = i; #ifdef ATA_STATIC_ID if (ch->devices & ((ATA_ATA_MASTER << i))) unit = (device_get_unit(dev) << 1) + i; #endif - if (!(childdevs[i] = ata_add_child(dev, devices[i], unit))) { - free(devices[i], M_ATA); - devices[i]=NULL; - } - else { - if (ata_getparam(devices[i], 1)) { - device_delete_child(dev, childdevs[i]); - free(devices[i], M_ATA); - childdevs[i] = NULL; - devices[i] = NULL; + if ((child = ata_add_child(dev, atadev, unit))) { + if (ata_getparam(atadev, 1)) { + device_delete_child(dev, child); + free(atadev, M_ATA); } } + else + free(atadev, M_ATA); } - devices[i] = NULL; - childdevs[i] = NULL; } - bus_generic_probe(dev); bus_generic_attach(dev); return 0; @@ -895,6 +889,16 @@ ata_mode2str(int mode) } int +ata_atapi(device_t dev) +{ + struct ata_channel *ch = device_get_softc(device_get_parent(dev)); + struct ata_device *atadev = device_get_softc(dev); + + return ((atadev->unit == ATA_MASTER && ch->devices & ATA_ATAPI_MASTER) || + (atadev->unit == ATA_SLAVE && ch->devices & ATA_ATAPI_SLAVE)); +} + +int ata_pmode(struct ata_params *ap) { if (ap->atavalid & ATA_FLAG_64_70) { Modified: head/sys/dev/ata/ata-all.h ============================================================================== --- head/sys/dev/ata/ata-all.h Thu Oct 9 12:25:07 2008 (r183723) +++ head/sys/dev/ata/ata-all.h Thu Oct 9 12:56:57 2008 (r183724) @@ -563,6 +563,7 @@ void ata_modify_if_48bit(struct ata_requ void ata_udelay(int interval); char *ata_unit2str(struct ata_device *atadev); char *ata_mode2str(int mode); +int ata_atapi(device_t dev); int ata_pmode(struct ata_params *ap); int ata_wmode(struct ata_params *ap); int ata_umode(struct ata_params *ap); Modified: head/sys/dev/ata/ata-dma.c ============================================================================== --- head/sys/dev/ata/ata-dma.c Thu Oct 9 12:25:07 2008 (r183723) +++ head/sys/dev/ata/ata-dma.c Thu Oct 9 12:56:57 2008 (r183724) @@ -81,7 +81,7 @@ ata_dmainit(device_t dev) ch->dma.segsize = 63536; ch->dma.max_iosize = 128 * DEV_BSIZE; ch->dma.max_address = BUS_SPACE_MAXADDR_32BIT; - ch->dma.dma_slots = 2; + ch->dma.dma_slots = 6; if (bus_dma_tag_create(bus_get_dma_tag(dev), ch->dma.alignment, 0, ch->dma.max_address, BUS_SPACE_MAXADDR, Modified: head/sys/dev/ata/ata-pci.c ============================================================================== --- head/sys/dev/ata/ata-pci.c Thu Oct 9 12:25:07 2008 (r183723) +++ head/sys/dev/ata/ata-pci.c Thu Oct 9 12:56:57 2008 (r183724) @@ -54,140 +54,34 @@ static MALLOC_DEFINE(M_ATAPCI, "ata_pci" /* misc defines */ #define IOMASK 0xfffffffc -#define ATA_PROBE_OK -10 - -int -ata_legacy(device_t dev) -{ - return (((pci_read_config(dev, PCIR_PROGIF, 1)&PCIP_STORAGE_IDE_MASTERDEV)&& - ((pci_read_config(dev, PCIR_PROGIF, 1) & - (PCIP_STORAGE_IDE_MODEPRIM | PCIP_STORAGE_IDE_MODESEC)) != - (PCIP_STORAGE_IDE_MODEPRIM | PCIP_STORAGE_IDE_MODESEC))) || - (!pci_read_config(dev, PCIR_BAR(0), 4) && - !pci_read_config(dev, PCIR_BAR(1), 4) && - !pci_read_config(dev, PCIR_BAR(2), 4) && - !pci_read_config(dev, PCIR_BAR(3), 4) && - !pci_read_config(dev, PCIR_BAR(5), 4))); -} +/* local prototypes */ +static int ata_generic_chipinit(device_t dev); +static void ata_generic_setmode(device_t dev, int mode); + +/* + * generic PCI ATA device probe + */ int ata_pci_probe(device_t dev) { + struct ata_pci_controller *ctlr = device_get_softc(dev); + char buffer[64]; + + /* is this a storage class device ? */ if (pci_get_class(dev) != PCIC_STORAGE) return ENXIO; - /* if this is an AHCI chipset grab it */ - if (pci_get_subclass(dev) == PCIS_STORAGE_SATA) { - if (!ata_ahci_ident(dev)) - return ATA_PROBE_OK; - } - - /* run through the vendor specific drivers */ - switch (pci_get_vendor(dev)) { - case ATA_ACARD_ID: - if (!ata_acard_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_ACER_LABS_ID: - if (!ata_ali_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_AMD_ID: - if (!ata_amd_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_ADAPTEC_ID: - if (!ata_adaptec_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_ATI_ID: - if (!ata_ati_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_CYRIX_ID: - if (!ata_cyrix_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_CYPRESS_ID: - if (!ata_cypress_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_HIGHPOINT_ID: - if (!ata_highpoint_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_INTEL_ID: - if (!ata_intel_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_ITE_ID: - if (!ata_ite_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_JMICRON_ID: - if (!ata_jmicron_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_MARVELL_ID: - if (!ata_marvell_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_NATIONAL_ID: - if (!ata_national_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_NETCELL_ID: - if (!ata_netcell_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_NVIDIA_ID: - if (!ata_nvidia_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_PROMISE_ID: - if (!ata_promise_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_SERVERWORKS_ID: - if (!ata_serverworks_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_SILICON_IMAGE_ID: - if (!ata_sii_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_SIS_ID: - if (!ata_sis_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_VIA_ID: - if (!ata_via_ident(dev)) - return ATA_PROBE_OK; - break; - case ATA_CENATEK_ID: - if (pci_get_devid(dev) == ATA_CENATEK_ROCKET) { - ata_generic_ident(dev); - device_set_desc(dev, "Cenatek Rocket Drive controller"); - return ATA_PROBE_OK; - } - break; - case ATA_MICRON_ID: - if (pci_get_devid(dev) == ATA_MICRON_RZ1000 || - pci_get_devid(dev) == ATA_MICRON_RZ1001) { - ata_generic_ident(dev); - device_set_desc(dev, - "RZ 100? ATA controller !WARNING! data loss/corruption risk"); - return ATA_PROBE_OK; - } - break; - } + /* is this an IDE/ATA type device ? */ + if (pci_get_subclass(dev) != PCIS_STORAGE_IDE) + return ENXIO; + + sprintf(buffer, "%s ATA controller", ata_pcivendor2str(dev)); + device_set_desc_copy(dev, buffer); + ctlr->chipinit = ata_generic_chipinit; - /* unknown chipset, try generic DMA if it seems possible */ - if (pci_get_subclass(dev) == PCIS_STORAGE_IDE) { - if (!ata_generic_ident(dev)) - return ATA_PROBE_OK; - } - return ENXIO; + /* we are a low priority handler */ + return -100; } int @@ -286,7 +180,6 @@ ata_pci_resume(device_t dev) return error; } - struct resource * ata_pci_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags) @@ -414,6 +307,28 @@ ata_pci_teardown_intr(device_t dev, devi } } +static void +ata_generic_setmode(device_t dev, int mode) +{ + struct ata_device *atadev = device_get_softc(dev); + + mode = ata_limit_mode(dev, mode, ATA_UDMA2); + mode = ata_check_80pin(dev, mode); + if (!ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode)) + atadev->mode = mode; +} + +static int +ata_generic_chipinit(device_t dev) +{ + struct ata_pci_controller *ctlr = device_get_softc(dev); + + if (ata_setup_interrupt(dev, ata_generic_intr)) + return ENXIO; + ctlr->setmode = ata_generic_setmode; + return 0; +} + int ata_pci_allocate(device_t dev) { @@ -545,35 +460,6 @@ ata_pci_dmainit(device_t dev) ch->dma.reset = ata_pci_dmareset; } -char * -ata_pcivendor2str(device_t dev) -{ - switch (pci_get_vendor(dev)) { - case ATA_ACARD_ID: return "Acard"; - case ATA_ACER_LABS_ID: return "AcerLabs"; - case ATA_AMD_ID: return "AMD"; - case ATA_ADAPTEC_ID: return "Adaptec"; - case ATA_ATI_ID: return "ATI"; - case ATA_CYRIX_ID: return "Cyrix"; - case ATA_CYPRESS_ID: return "Cypress"; - case ATA_HIGHPOINT_ID: return "HighPoint"; - case ATA_INTEL_ID: return "Intel"; - case ATA_ITE_ID: return "ITE"; - case ATA_JMICRON_ID: return "JMicron"; - case ATA_MARVELL_ID: return "Marvell"; - case ATA_NATIONAL_ID: return "National"; - case ATA_NETCELL_ID: return "Netcell"; - case ATA_NVIDIA_ID: return "nVidia"; - case ATA_PROMISE_ID: return "Promise"; - case ATA_SERVERWORKS_ID: return "ServerWorks"; - case ATA_SILICON_IMAGE_ID: return "SiI"; - case ATA_SIS_ID: return "SiS"; - case ATA_VIA_ID: return "VIA"; - case ATA_CENATEK_ID: return "Cenatek"; - case ATA_MICRON_ID: return "Micron"; - default: return "Generic"; - } -} static device_method_t ata_pci_methods[] = { /* device interface */ @@ -595,7 +481,7 @@ static device_method_t ata_pci_methods[] { 0, 0 } }; -devclass_t atapci_devclass; +devclass_t ata_pci_devclass; static driver_t ata_pci_driver = { "atapci", @@ -603,7 +489,7 @@ static driver_t ata_pci_driver = { sizeof(struct ata_pci_controller), }; -DRIVER_MODULE(atapci, pci, ata_pci_driver, atapci_devclass, 0, 0); +DRIVER_MODULE(atapci, pci, ata_pci_driver, ata_pci_devclass, 0, 0); MODULE_VERSION(atapci, 1); MODULE_DEPEND(atapci, ata, 1, 1, 1); @@ -728,3 +614,171 @@ driver_t ata_pcichannel_driver = { }; DRIVER_MODULE(ata, atapci, ata_pcichannel_driver, ata_devclass, 0, 0); + + +/* + * misc support fucntions + */ +int +ata_legacy(device_t dev) +{ + return (((pci_read_config(dev, PCIR_PROGIF, 1)&PCIP_STORAGE_IDE_MASTERDEV)&& + ((pci_read_config(dev, PCIR_PROGIF, 1) & + (PCIP_STORAGE_IDE_MODEPRIM | PCIP_STORAGE_IDE_MODESEC)) != + (PCIP_STORAGE_IDE_MODEPRIM | PCIP_STORAGE_IDE_MODESEC))) || + (!pci_read_config(dev, PCIR_BAR(0), 4) && + !pci_read_config(dev, PCIR_BAR(1), 4) && + !pci_read_config(dev, PCIR_BAR(2), 4) && + !pci_read_config(dev, PCIR_BAR(3), 4) && + !pci_read_config(dev, PCIR_BAR(5), 4))); +} + +void +ata_generic_intr(void *data) +{ + struct ata_pci_controller *ctlr = data; + struct ata_channel *ch; + int unit; + + for (unit = 0; unit < ctlr->channels; unit++) { + if ((ch = ctlr->interrupt[unit].argument)) + ctlr->interrupt[unit].function(ch); + } +} + +int +ata_setup_interrupt(device_t dev, void *intr_func) +{ + struct ata_pci_controller *ctlr = device_get_softc(dev); + int rid = ATA_IRQ_RID; + + if (!ata_legacy(dev)) { + if (!(ctlr->r_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, + RF_SHAREABLE | RF_ACTIVE))) { + device_printf(dev, "unable to map interrupt\n"); + return ENXIO; + } + if ((bus_setup_intr(dev, ctlr->r_irq, ATA_INTR_FLAGS, NULL, + intr_func, ctlr, &ctlr->handle))) { + /* SOS XXX release r_irq */ + device_printf(dev, "unable to setup interrupt\n"); + return ENXIO; + } + } + return 0; +} + +void +ata_set_desc(device_t dev) +{ + struct ata_pci_controller *ctlr = device_get_softc(dev); + char buffer[128]; + + sprintf(buffer, "%s %s %s controller", + ata_pcivendor2str(dev), ctlr->chip->text, + ata_mode2str(ctlr->chip->max_dma)); + device_set_desc_copy(dev, buffer); +} + +struct ata_chip_id * +ata_match_chip(device_t dev, struct ata_chip_id *index) +{ + while (index->chipid != 0) { + if (pci_get_devid(dev) == index->chipid && + pci_get_revid(dev) >= index->chiprev) + return index; + index++; + } + return NULL; +} + +struct ata_chip_id * +ata_find_chip(device_t dev, struct ata_chip_id *index, int slot) +{ + device_t *children; + int nchildren, i; + + if (device_get_children(device_get_parent(dev), &children, &nchildren)) + return 0; + + while (index->chipid != 0) { + for (i = 0; i < nchildren; i++) { + if (((slot >= 0 && pci_get_slot(children[i]) == slot) || + (slot < 0 && pci_get_slot(children[i]) <= -slot)) && + pci_get_devid(children[i]) == index->chipid && + pci_get_revid(children[i]) >= index->chiprev) { + free(children, M_TEMP); + return index; + } + } + index++; + } + free(children, M_TEMP); + return NULL; +} + +void +ata_print_cable(device_t dev, u_int8_t *who) +{ + device_printf(dev, + "DMA limited to UDMA33, %s found non-ATA66 cable\n", who); +} + +int +ata_check_80pin(device_t dev, int mode) +{ + struct ata_device *atadev = device_get_softc(dev); + + if (!ata_dma_check_80pin) { + if (bootverbose) + device_printf(dev, "Skipping 80pin cable check\n"); + return mode; + } + + if (mode > ATA_UDMA2 && !(atadev->param.hwres & ATA_CABLE_ID)) { + ata_print_cable(dev, "device"); + mode = ATA_UDMA2; + } + return mode; +} + +char * +ata_pcivendor2str(device_t dev) +{ + switch (pci_get_vendor(dev)) { + case ATA_ACARD_ID: return "Acard"; + case ATA_ACER_LABS_ID: return "AcerLabs"; + case ATA_AMD_ID: return "AMD"; + case ATA_ADAPTEC_ID: return "Adaptec"; + case ATA_ATI_ID: return "ATI"; + case ATA_CYRIX_ID: return "Cyrix"; + case ATA_CYPRESS_ID: return "Cypress"; + case ATA_HIGHPOINT_ID: return "HighPoint"; + case ATA_INTEL_ID: return "Intel"; + case ATA_ITE_ID: return "ITE"; + case ATA_JMICRON_ID: return "JMicron"; + case ATA_MARVELL_ID: return "Marvell"; + case ATA_NATIONAL_ID: return "National"; + case ATA_NETCELL_ID: return "Netcell"; + case ATA_NVIDIA_ID: return "nVidia"; + case ATA_PROMISE_ID: return "Promise"; + case ATA_SERVERWORKS_ID: return "ServerWorks"; + case ATA_SILICON_IMAGE_ID: return "SiI"; + case ATA_SIS_ID: return "SiS"; + case ATA_VIA_ID: return "VIA"; + case ATA_CENATEK_ID: return "Cenatek"; + case ATA_MICRON_ID: return "Micron"; + default: return "Generic"; + } +} + +int +ata_mode2idx(int mode) +{ + if ((mode & ATA_DMA_MASK) == ATA_UDMA0) + return (mode & ATA_MODE_MASK) + 8; + if ((mode & ATA_DMA_MASK) == ATA_WDMA0) + return (mode & ATA_MODE_MASK) + 5; + return (mode & ATA_MODE_MASK) - ATA_PIO0; +} + Modified: head/sys/dev/ata/ata-pci.h ============================================================================== --- head/sys/dev/ata/ata-pci.h Thu Oct 9 12:25:07 2008 (r183723) +++ head/sys/dev/ata/ata-pci.h Thu Oct 9 12:56:57 2008 (r183724) @@ -395,79 +395,6 @@ struct ata_connect_task { #define ATA_VIA6420 0x31491106 #define ATA_VIA6421 0x32491106 -/* chipset setup related defines */ -#define AHCI 1 -#define ATPOLD 1 - -#define ALIOLD 0x01 -#define ALINEW 0x02 -#define ALISATA 0x04 - -#define ATIPATA 0x01 -#define ATISATA 0x02 -#define ATIAHCI 0x04 - -#define HPT366 0 -#define HPT370 1 -#define HPT372 2 -#define HPT374 3 -#define HPTOLD 0x01 - -#define MV50XX 50 -#define MV60XX 60 -#define MV61XX 61 - -#define PROLD 0 -#define PRNEW 1 -#define PRTX 2 -#define PRMIO 3 -#define PRTX4 0x01 -#define PRSX4X 0x02 -#define PRSX6K 0x04 -#define PRPATA 0x08 -#define PRCMBO 0x10 -#define PRCMBO2 0x20 -#define PRSATA 0x40 -#define PRSATA2 0x80 - -#define SWKS33 0 -#define SWKS66 1 -#define SWKS100 2 -#define SWKSMIO 3 - -#define SIIMEMIO 1 -#define SIIPRBIO 2 -#define SIIINTR 0x01 -#define SIISETCLK 0x02 -#define SIIBUG 0x04 -#define SII4CH 0x08 - -#define SIS_SOUTH 1 -#define SISSATA 2 -#define SIS133NEW 3 -#define SIS133OLD 4 -#define SIS100NEW 5 -#define SIS100OLD 6 -#define SIS66 7 -#define SIS33 8 - -#define VIA33 0 -#define VIA66 1 -#define VIA100 2 -#define VIA133 3 -#define AMDNVIDIA 4 - -#define AMDCABLE 0x0001 -#define AMDBUG 0x0002 -#define NVIDIA 0x0004 -#define NV4 0x0010 -#define NVQ 0x0020 -#define VIACLK 0x0100 -#define VIABUG 0x0200 -#define VIABAR 0x0400 -#define VIAAHCI 0x0800 - - /* global prototypes ata-pci.c */ int ata_pci_probe(device_t dev); int ata_pci_attach(device_t dev); @@ -483,32 +410,62 @@ int ata_pci_status(device_t dev); void ata_pci_hw(device_t dev); void ata_pci_dmainit(device_t dev); char *ata_pcivendor2str(device_t dev); - - -/* global prototypes ata-chipset.c */ -int ata_generic_ident(device_t); -int ata_ahci_ident(device_t); -int ata_acard_ident(device_t); -int ata_ali_ident(device_t); -int ata_amd_ident(device_t); -int ata_adaptec_ident(device_t); -int ata_ati_ident(device_t); -int ata_cyrix_ident(device_t); -int ata_cypress_ident(device_t); -int ata_highpoint_ident(device_t); -int ata_intel_ident(device_t); -int ata_ite_ident(device_t); -int ata_jmicron_ident(device_t); -int ata_marvell_ident(device_t); -int ata_national_ident(device_t); -int ata_nvidia_ident(device_t); -int ata_netcell_ident(device_t); -int ata_promise_ident(device_t); -int ata_serverworks_ident(device_t); -int ata_sii_ident(device_t); -int ata_sis_ident(device_t); -int ata_via_ident(device_t); int ata_legacy(device_t); +void ata_generic_intr(void *data); +int ata_setup_interrupt(device_t dev, void *intr_func); +void ata_set_desc(device_t dev); +struct ata_chip_id *ata_match_chip(device_t dev, struct ata_chip_id *index); +struct ata_chip_id *ata_find_chip(device_t dev, struct ata_chip_id *index, int slot); +void ata_print_cable(device_t dev, u_int8_t *who); +int ata_check_80pin(device_t dev, int mode); +int ata_mode2idx(int mode); + +/* global prototypes ata-sata.c */ +void ata_sata_phy_event(void *context, int dummy); +void ata_sata_phy_check_events(device_t dev); +int ata_sata_phy_reset(device_t dev); +void ata_sata_setmode(device_t dev, int mode); +int ata_request2fis_h2d(struct ata_request *request, u_int8_t *fis); +void ata_pm_identify(device_t dev); + +/* global prototypes from chipsets/ata-*.c */ +int ata_ahci_chipinit(device_t); +int ata_ahci_allocate(device_t dev); +void ata_ahci_reset(device_t dev); +void ata_ahci_dmainit(device_t dev); +int ata_marvell_edma_chipinit(device_t); +int ata_sii_chipinit(device_t); /* global prototypes ata-dma.c */ void ata_dmainit(device_t); + +/* externs */ +extern devclass_t ata_pci_devclass; + +/* macro for easy definition of all driver module stuff */ +#define ATA_DECLARE_DRIVER(dname) \ +static device_method_t __CONCAT(dname,_methods)[] = { \ + DEVMETHOD(device_probe, __CONCAT(dname,_probe)), \ + DEVMETHOD(device_attach, ata_pci_attach), \ + DEVMETHOD(device_detach, ata_pci_detach), \ + DEVMETHOD(device_suspend, bus_generic_suspend), \ + DEVMETHOD(device_resume, bus_generic_resume), \ + DEVMETHOD(device_shutdown, bus_generic_shutdown), \ + DEVMETHOD(bus_alloc_resource, ata_pci_alloc_resource), \ + DEVMETHOD(bus_release_resource, ata_pci_release_resource), \ + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), \ + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), \ + DEVMETHOD(bus_setup_intr, ata_pci_setup_intr), \ + DEVMETHOD(bus_teardown_intr, ata_pci_teardown_intr), \ + { 0, 0 } \ +}; \ +static driver_t __CONCAT(dname,_driver) = { \ + "atapci", \ + __CONCAT(dname,_methods), \ + sizeof(struct ata_pci_controller) \ +}; \ +DRIVER_MODULE(dname, pci, __CONCAT(dname,_driver), ata_pci_devclass, 0, 0); \ +MODULE_VERSION(dname, 1); \ +MODULE_DEPEND(dname, ata, 1, 1, 1); \ +MODULE_DEPEND(dname, atapci, 1, 1, 1); + Added: head/sys/dev/ata/ata-sata.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/ata/ata-sata.c Thu Oct 9 12:56:57 2008 (r183724) @@ -0,0 +1,357 @@ +/*- + * Copyright (c) 1998 - 2008 Søren Schmidt + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * without modification, immediately at the beginning of the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_ata.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * SATA support functions + */ +void +ata_sata_phy_event(void *context, int dummy) +{ + struct ata_connect_task *tp = (struct ata_connect_task *)context; + struct ata_channel *ch = device_get_softc(tp->dev); + device_t *children; + int nchildren, i; + + mtx_lock(&Giant); /* newbus suckage it needs Giant */ + if (tp->action == ATA_C_ATTACH) { + if (bootverbose) + device_printf(tp->dev, "CONNECTED\n"); + ATA_RESET(tp->dev); + ata_identify(tp->dev); + } + if (tp->action == ATA_C_DETACH) { + if (!device_get_children(tp->dev, &children, &nchildren)) { + for (i = 0; i < nchildren; i++) + if (children[i]) + device_delete_child(tp->dev, children[i]); + free(children, M_TEMP); + } + mtx_lock(&ch->state_mtx); + ch->state = ATA_IDLE; + mtx_unlock(&ch->state_mtx); + if (bootverbose) + device_printf(tp->dev, "DISCONNECTED\n"); + } + mtx_unlock(&Giant); /* suckage code dealt with, release Giant */ + free(tp, M_ATA); +} + +void +ata_sata_phy_check_events(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + u_int32_t error = ATA_IDX_INL(ch, ATA_SERROR); + + /* clear error bits/interrupt */ + ATA_IDX_OUTL(ch, ATA_SERROR, error); + + /* do we have any events flagged ? */ + if (error) { + struct ata_connect_task *tp; + u_int32_t status = ATA_IDX_INL(ch, ATA_SSTATUS); + + /* if we have a connection event deal with it */ + if ((error & ATA_SE_PHY_CHANGED) && + (tp = (struct ata_connect_task *) + malloc(sizeof(struct ata_connect_task), + M_ATA, M_NOWAIT | M_ZERO))) { + + if (((status & ATA_SS_CONWELL_MASK) == ATA_SS_CONWELL_GEN1) || + ((status & ATA_SS_CONWELL_MASK) == ATA_SS_CONWELL_GEN2)) { + if (bootverbose) + device_printf(dev, "CONNECT requested\n"); + tp->action = ATA_C_ATTACH; + } + else { + if (bootverbose) + device_printf(dev, "DISCONNECT requested\n"); + tp->action = ATA_C_DETACH; + } + tp->dev = dev; + TASK_INIT(&tp->task, 0, ata_sata_phy_event, tp); + taskqueue_enqueue(taskqueue_thread, &tp->task); + } + } +} + +static int +ata_sata_connect(struct ata_channel *ch) +{ + u_int32_t status; + int timeout; + + /* wait up to 1 second for "connect well" */ + for (timeout = 0; timeout < 100 ; timeout++) { + status = ATA_IDX_INL(ch, ATA_SSTATUS); + if ((status & ATA_SS_CONWELL_MASK) == ATA_SS_CONWELL_GEN1 || + (status & ATA_SS_CONWELL_MASK) == ATA_SS_CONWELL_GEN2) + break; + ata_udelay(10000); + } + if (timeout >= 100) { + if (bootverbose) + device_printf(ch->dev, "SATA connect status=%08x\n", status); + return 0; + } + if (bootverbose) + device_printf(ch->dev, "SATA connect time=%dms\n", timeout * 10); + + /* clear SATA error register */ + ATA_IDX_OUTL(ch, ATA_SERROR, ATA_IDX_INL(ch, ATA_SERROR)); + + return 1; +} + +int +ata_sata_phy_reset(device_t dev) +{ + struct ata_channel *ch = device_get_softc(dev); + int loop, retry; + + if ((ATA_IDX_INL(ch, ATA_SCONTROL) & ATA_SC_DET_MASK) == ATA_SC_DET_IDLE) + return ata_sata_connect(ch); + + for (retry = 0; retry < 10; retry++) { + for (loop = 0; loop < 10; loop++) { + ATA_IDX_OUTL(ch, ATA_SCONTROL, ATA_SC_DET_RESET); + ata_udelay(100); + if ((ATA_IDX_INL(ch, ATA_SCONTROL) & ATA_SC_DET_MASK) == + ATA_SC_DET_RESET) + break; + } + ata_udelay(5000); + for (loop = 0; loop < 10; loop++) { + ATA_IDX_OUTL(ch, ATA_SCONTROL, ATA_SC_DET_IDLE | + ATA_SC_IPM_DIS_PARTIAL | + ATA_SC_IPM_DIS_SLUMBER); + ata_udelay(100); + if ((ATA_IDX_INL(ch, ATA_SCONTROL) & ATA_SC_DET_MASK) == 0) + return ata_sata_connect(ch); + } + } + return 0; +} + +void +ata_sata_setmode(device_t dev, int mode) +{ + struct ata_device *atadev = device_get_softc(dev); + + /* + * if we detect that the device isn't a real SATA device we limit + * the transfer mode to UDMA5/ATA100. + * this works around the problems some devices has with the + * Marvell 88SX8030 SATA->PATA converters and UDMA6/ATA133. + */ + if (atadev->param.satacapabilities != 0x0000 && + atadev->param.satacapabilities != 0xffff) { + struct ata_channel *ch = device_get_softc(device_get_parent(dev)); + + /* on some drives we need to set the transfer mode */ + ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0, + ata_limit_mode(dev, mode, ATA_UDMA6)); + + /* query SATA STATUS for the speed */ + if (ch->r_io[ATA_SSTATUS].res && + ((ATA_IDX_INL(ch, ATA_SSTATUS) & ATA_SS_CONWELL_MASK) == + ATA_SS_CONWELL_GEN2)) + atadev->mode = ATA_SA300; + else + atadev->mode = ATA_SA150; + } + else { + mode = ata_limit_mode(dev, mode, ATA_UDMA5); + if (!ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode)) + atadev->mode = mode; + } +} + +int +ata_request2fis_h2d(struct ata_request *request, u_int8_t *fis) +{ + struct ata_device *atadev = device_get_softc(request->dev); + + if (request->flags & ATA_R_ATAPI) { + fis[0] = 0x27; /* host to device */ + fis[1] = 0x80 | (atadev->unit & 0x0f); + fis[2] = ATA_PACKET_CMD; + if (request->flags & (ATA_R_READ | ATA_R_WRITE)) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From jkoshy at FreeBSD.org Thu Oct 9 14:55:46 2008 From: jkoshy at FreeBSD.org (Joseph Koshy) Date: Thu Oct 9 14:55:52 2008 Subject: svn commit: r183725 - in head: lib/libpmc sys/dev/hwpmc sys/sys Message-ID: <200810091455.m99EtkuB064638@svn.freebsd.org> Author: jkoshy Date: Thu Oct 9 14:55:45 2008 New Revision: 183725 URL: http://svn.freebsd.org/changeset/base/183725 Log: - Sparsely number enumerations 'pmc_cputype' and 'pmc_event' in order to reduce ABI disruptions when new cpu types and new PMC events are added in the future. - Support alternate spellings for PMC events. Derive the canonical spelling of an event name from its enumeration name in 'enum pmc_event'. - Provide a way for users to disambiguate between identically named events supported by multiple classes of PMCs in a CPU. - Change libpmc's machine-dependent event specifier parsing code to better support CPUs containing two or more classes of PMC resources. Modified: head/lib/libpmc/libpmc.c head/sys/dev/hwpmc/pmc_events.h head/sys/sys/pmc.h Modified: head/lib/libpmc/libpmc.c ============================================================================== --- head/lib/libpmc/libpmc.c Thu Oct 9 12:56:57 2008 (r183724) +++ head/lib/libpmc/libpmc.c Thu Oct 9 14:55:45 2008 (r183725) @@ -59,6 +59,10 @@ static int p5_allocate_pmc(enum pmc_even static int p6_allocate_pmc(enum pmc_event _pe, char *_ctrspec, struct pmc_op_pmcallocate *_pmc_config); #endif +#if defined(__amd64__) || defined(__i386__) +static int tsc_allocate_pmc(enum pmc_event _pe, char *_ctrspec, + struct pmc_op_pmcallocate *_pmc_config); +#endif #define PMC_CALL(cmd, params) \ syscall(pmc_syscall, PMC_OP_##cmd, (params)) @@ -77,23 +81,96 @@ struct pmc_event_alias { static const struct pmc_event_alias *pmc_mdep_event_aliases; /* - * The pmc_event_descr table maps symbolic names known to the user + * The pmc_event_descr structure maps symbolic names known to the user * to integer codes used by the PMC KLD. */ struct pmc_event_descr { const char *pm_ev_name; enum pmc_event pm_ev_code; - enum pmc_class pm_ev_class; }; -static const struct pmc_event_descr -pmc_event_table[] = +/* + * The pmc_class_descr structure maps class name prefixes for + * event names to event tables and other PMC class data. + */ +struct pmc_class_descr { + const char *pm_evc_name; + size_t pm_evc_name_size; + enum pmc_class pm_evc_class; + const struct pmc_event_descr *pm_evc_event_table; + size_t pm_evc_event_table_size; + int (*pm_evc_allocate_pmc)(enum pmc_event _pe, + char *_ctrspec, struct pmc_op_pmcallocate *_pa); +}; + +#define PMC_TABLE_SIZE(N) (sizeof(N)/sizeof(N[0])) +#define PMC_EVENT_TABLE_SIZE(N) PMC_TABLE_SIZE(N##_event_table) + +#undef __PMC_EV +#define __PMC_EV(C,N) { #N, PMC_EV_ ## C ## _ ## N }, + +/* + * PMC_MDEP_TABLE(NAME, CLASS, ADDITIONAL_CLASSES...) + * + * Build an event descriptor table and a list of valid PMC classes. + */ +#define PMC_MDEP_TABLE(N,C,...) \ + static const struct pmc_event_descr N##_event_table[] = \ + { \ + __PMC_EV_##C() \ + }; \ + static const enum pmc_class N##_pmc_classes[] = { \ + PMC_CLASS_##C, __VA_ARGS__ \ + } + +PMC_MDEP_TABLE(k7, K7, PMC_CLASS_TSC); +PMC_MDEP_TABLE(k8, K8, PMC_CLASS_TSC); +PMC_MDEP_TABLE(p4, P4, PMC_CLASS_TSC); +PMC_MDEP_TABLE(p5, P5, PMC_CLASS_TSC); +PMC_MDEP_TABLE(p6, P6, PMC_CLASS_TSC); + +static const struct pmc_event_descr tsc_event_table[] = { -#undef __PMC_EV -#define __PMC_EV(C,N,EV) { #EV, PMC_EV_ ## C ## _ ## N, PMC_CLASS_ ## C }, - __PMC_EVENTS() + __PMC_EV_TSC() }; +#undef PMC_CLASS_TABLE_DESC +#define PMC_CLASS_TABLE_DESC(N, C) { \ + .pm_evc_name = #N "-", \ + .pm_evc_name_size = sizeof(#N "-") - 1, \ + .pm_evc_class = PMC_CLASS_##C , \ + .pm_evc_event_table = N##_event_table , \ + .pm_evc_event_table_size = \ + PMC_EVENT_TABLE_SIZE(N), \ + .pm_evc_allocate_pmc = N##_allocate_pmc \ + } + +static const struct pmc_class_descr pmc_class_table[] = +{ +#if defined(__i386__) + PMC_CLASS_TABLE_DESC(k7, K7), +#endif +#if defined(__i386__) || defined(__amd64__) + PMC_CLASS_TABLE_DESC(k8, K8), + PMC_CLASS_TABLE_DESC(p4, P4), +#endif +#if defined(__i386__) + PMC_CLASS_TABLE_DESC(p5, P5), + PMC_CLASS_TABLE_DESC(p6, P6), +#endif +#if defined(__i386__) || defined(__amd64__) + PMC_CLASS_TABLE_DESC(tsc, TSC) +#endif +}; + +static size_t pmc_event_class_table_size = + PMC_TABLE_SIZE(pmc_class_table); + +#undef PMC_CLASS_TABLE_DESC + +static const enum pmc_class *pmc_mdep_class_list; +static size_t pmc_mdep_class_list_size; + /* * Mapping tables, mapping enumeration values to human readable * strings. @@ -111,9 +188,14 @@ static const char * pmc_class_names[] = __PMC_CLASSES() }; -static const char * pmc_cputype_names[] = { +struct pmc_cputype_map { + enum pmc_class pm_cputype; + const char *pm_name; +}; + +static const struct pmc_cputype_map pmc_cputype_names[] = { #undef __PMC_CPU -#define __PMC_CPU(S, D) #S , +#define __PMC_CPU(S, V, D) { .pm_cputype = PMC_CPU_##S, .pm_name = #S } , __PMC_CPUS() }; @@ -139,11 +221,6 @@ static int pmc_syscall = -1; /* filled static struct pmc_cpuinfo cpu_info; /* filled in by pmc_init() */ - -/* Architecture dependent event parsing */ -static int (*pmc_mdep_allocate_pmc)(enum pmc_event _pe, char *_ctrspec, - struct pmc_op_pmcallocate *_pmc_config); - /* Event masks for events */ struct pmc_masks { const char *pm_name; @@ -167,7 +244,8 @@ pmc_parse_mask(const struct pmc_masks *p return (-1); c = 0; /* count of mask keywords seen */ while ((r = strsep(&q, "+")) != NULL) { - for (pm = pmask; pm->pm_name && strcmp(r, pm->pm_name); pm++) + for (pm = pmask; pm->pm_name && strcasecmp(r, pm->pm_name); + pm++) ; if (pm->pm_name == NULL) /* not found */ return (-1); @@ -215,14 +293,7 @@ k7_allocate_pmc(enum pmc_event pe, char uint32_t count, unitmask; pmc_config->pm_md.pm_amd.pm_amd_config = 0; - pmc_config->pm_caps |= PMC_CAP_READ; - - if (pe == PMC_EV_TSC_TSC) { - /* TSC events must be unqualified. */ - if (ctrspec && *ctrspec != '\0') - return (-1); - return (0); - } + pmc_config->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE); if (pe == PMC_EV_K7_DC_REFILLS_FROM_L2 || pe == PMC_EV_K7_DC_REFILLS_FROM_SYSTEM || @@ -232,8 +303,6 @@ k7_allocate_pmc(enum pmc_event pe, char } else unitmask = has_unitmask = 0; - pmc_config->pm_caps |= PMC_CAP_WRITE; - while ((p = strsep(&ctrspec, ",")) != NULL) { if (KWPREFIXMATCH(p, K7_KW_COUNT "=")) { q = strchr(p, '='); @@ -514,16 +583,9 @@ k8_allocate_pmc(enum pmc_event pe, char uint32_t count, evmask; const struct pmc_masks *pm, *pmask; - pmc_config->pm_caps |= PMC_CAP_READ; + pmc_config->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE); pmc_config->pm_md.pm_amd.pm_amd_config = 0; - if (pe == PMC_EV_TSC_TSC) { - /* TSC events must be unqualified. */ - if (ctrspec && *ctrspec != '\0') - return (-1); - return (0); - } - pmask = NULL; evmask = 0; @@ -597,8 +659,6 @@ k8_allocate_pmc(enum pmc_event pe, char break; /* no options defined */ } - pmc_config->pm_caps |= PMC_CAP_WRITE; - while ((p = strsep(&ctrspec, ",")) != NULL) { if (KWPREFIXMATCH(p, K8_KW_COUNT "=")) { q = strchr(p, '='); @@ -1005,22 +1065,14 @@ p4_allocate_pmc(enum pmc_event pe, char uint32_t evmask, cccractivemask; const struct pmc_masks *pm, *pmask; - pmc_config->pm_caps |= PMC_CAP_READ; + pmc_config->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE); pmc_config->pm_md.pm_p4.pm_p4_cccrconfig = pmc_config->pm_md.pm_p4.pm_p4_escrconfig = 0; - if (pe == PMC_EV_TSC_TSC) { - /* TSC must not be further qualified */ - if (ctrspec && *ctrspec != '\0') - return (-1); - return (0); - } - pmask = NULL; evmask = 0; cccractivemask = 0x3; has_tag = has_busreqtype = 0; - pmc_config->pm_caps |= PMC_CAP_WRITE; #define __P4SETMASK(M) do { \ pmask = p4_mask_##M; \ @@ -1166,13 +1218,13 @@ p4_allocate_pmc(enum pmc_event pe, char if (*++q == '\0') /* skip '=' */ return (-1); - if (strcmp(q, P4_KW_ACTIVE_NONE) == 0) + if (strcasecmp(q, P4_KW_ACTIVE_NONE) == 0) cccractivemask = 0x0; - else if (strcmp(q, P4_KW_ACTIVE_SINGLE) == 0) + else if (strcasecmp(q, P4_KW_ACTIVE_SINGLE) == 0) cccractivemask = 0x1; - else if (strcmp(q, P4_KW_ACTIVE_BOTH) == 0) + else if (strcasecmp(q, P4_KW_ACTIVE_BOTH) == 0) cccractivemask = 0x2; - else if (strcmp(q, P4_KW_ACTIVE_ANY) == 0) + else if (strcasecmp(q, P4_KW_ACTIVE_ANY) == 0) cccractivemask = 0x3; else return (-1); @@ -1442,16 +1494,9 @@ p6_allocate_pmc(enum pmc_event pe, char int count, n; const struct pmc_masks *pm, *pmask; - pmc_config->pm_caps |= PMC_CAP_READ; + pmc_config->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE); pmc_config->pm_md.pm_ppro.pm_ppro_config = 0; - if (pe == PMC_EV_TSC_TSC) { - if (ctrspec && *ctrspec != '\0') - return (-1); - return (0); - } - - pmc_config->pm_caps |= PMC_CAP_WRITE; evmask = 0; #define P6MASKSET(M) pmask = p6_mask_ ## M @@ -1638,6 +1683,93 @@ p6_allocate_pmc(enum pmc_event pe, char #endif +#if defined(__i386__) || defined(__amd64__) +static int +tsc_allocate_pmc(enum pmc_event pe, char *ctrspec, + struct pmc_op_pmcallocate *pmc_config) +{ + if (pe != PMC_EV_TSC_TSC) + return (-1); + + /* TSC events must be unqualified. */ + if (ctrspec && *ctrspec != '\0') + return (-1); + + pmc_config->pm_md.pm_amd.pm_amd_config = 0; + pmc_config->pm_caps |= PMC_CAP_READ; + + return (0); +} +#endif + +/* + * Match an event name `name' with its canonical form. + * + * Matches are case insensitive and spaces, underscores and hyphen + * characters are considered to match each other. + * + * Returns 1 for a match, 0 otherwise. + */ + +static int +pmc_match_event_name(const char *name, const char *canonicalname) +{ + int cc, nc; + const unsigned char *c, *n; + + c = (const unsigned char *) canonicalname; + n = (const unsigned char *) name; + + for (; (nc = *n) && (cc = *c); n++, c++) { + + if (toupper(nc) == cc) + continue; + + if ((nc == ' ' || nc == '_' || nc == '-') && + (cc == ' ' || cc == '_' || cc == '-')) + continue; + + return (0); + } + + if (*n == '\0' && *c == '\0') + return (1); + + return (0); +} + +/* + * Match an event name against all the event named supported by a + * PMC class. + * + * Returns an event descriptor pointer on match or NULL otherwise. + */ +static const struct pmc_event_descr * +pmc_match_event_class(const char *name, + const struct pmc_class_descr *pcd) +{ + size_t n; + const struct pmc_event_descr *ev; + + ev = pcd->pm_evc_event_table; + for (n = 0; n < pcd->pm_evc_event_table_size; n++, ev++) + if (pmc_match_event_name(name, ev->pm_ev_name)) + return (ev); + + return (NULL); +} + +static int +pmc_mdep_is_compatible_class(enum pmc_class pc) +{ + size_t n; + + for (n = 0; n < pmc_mdep_class_list_size; n++) + if (pmc_mdep_class_list[n] == pc) + return (1); + return (0); +} + /* * API entry points */ @@ -1646,12 +1778,14 @@ int pmc_allocate(const char *ctrspec, enum pmc_mode mode, uint32_t flags, int cpu, pmc_id_t *pmcid) { + size_t n; int retval; - enum pmc_event pe; char *r, *spec_copy; const char *ctrname; - const struct pmc_event_alias *p; + const struct pmc_event_descr *ev; + const struct pmc_event_alias *alias; struct pmc_op_pmcallocate pmc_config; + const struct pmc_class_descr *pcd; spec_copy = NULL; retval = -1; @@ -1664,9 +1798,9 @@ pmc_allocate(const char *ctrspec, enum p /* replace an event alias with the canonical event specifier */ if (pmc_mdep_event_aliases) - for (p = pmc_mdep_event_aliases; p->pm_alias; p++) - if (!strcmp(ctrspec, p->pm_alias)) { - spec_copy = strdup(p->pm_spec); + for (alias = pmc_mdep_event_aliases; alias->pm_alias; alias++) + if (!strcasecmp(ctrspec, alias->pm_alias)) { + spec_copy = strdup(alias->pm_spec); break; } @@ -1676,19 +1810,43 @@ pmc_allocate(const char *ctrspec, enum p r = spec_copy; ctrname = strsep(&r, ","); - /* look for the given counter name */ - for (pe = PMC_EVENT_FIRST; pe < (PMC_EVENT_LAST+1); pe++) - if (!strcmp(ctrname, pmc_event_table[pe].pm_ev_name)) + /* + * If a explicit class prefix was given by the user, restrict the + * search for the event to the specified PMC class. + */ + ev = NULL; + for (n = 0; n < pmc_event_class_table_size; n++) { + pcd = &pmc_class_table[n]; + if (pmc_mdep_is_compatible_class(pcd->pm_evc_class) && + strncasecmp(ctrname, pcd->pm_evc_name, + pcd->pm_evc_name_size) == 0) { + if ((ev = pmc_match_event_class(ctrname + + pcd->pm_evc_name_size, pcd)) == NULL) { + errno = EINVAL; + goto out; + } break; + } + } - if (pe > PMC_EVENT_LAST) { + /* + * Otherwise, search for this event in all compatible PMC + * classes. + */ + for (n = 0; ev == NULL && n < pmc_event_class_table_size; n++) { + pcd = &pmc_class_table[n]; + if (pmc_mdep_is_compatible_class(pcd->pm_evc_class)) + ev = pmc_match_event_class(ctrname, pcd); + } + + if (ev == NULL) { errno = EINVAL; goto out; } bzero(&pmc_config, sizeof(pmc_config)); - pmc_config.pm_ev = pmc_event_table[pe].pm_ev_code; - pmc_config.pm_class = pmc_event_table[pe].pm_ev_class; + pmc_config.pm_ev = ev->pm_ev_code; + pmc_config.pm_class = pcd->pm_evc_class; pmc_config.pm_cpu = cpu; pmc_config.pm_mode = mode; pmc_config.pm_flags = flags; @@ -1696,7 +1854,7 @@ pmc_allocate(const char *ctrspec, enum p if (PMC_IS_SAMPLING_MODE(mode)) pmc_config.pm_caps |= PMC_CAP_INTERRUPT; - if (pmc_mdep_allocate_pmc(pe, r, &pmc_config) < 0) { + if (pcd->pm_evc_allocate_pmc(ev->pm_ev_code, r, &pmc_config) < 0) { errno = EINVAL; goto out; } @@ -1817,28 +1975,28 @@ pmc_event_names_of_class(enum pmc_class switch (cl) { case PMC_CLASS_TSC: - ev = &pmc_event_table[PMC_EV_TSC_TSC]; - count = 1; + ev = tsc_event_table; + count = PMC_EVENT_TABLE_SIZE(tsc); break; case PMC_CLASS_K7: - ev = &pmc_event_table[PMC_EV_K7_FIRST]; - count = PMC_EV_K7_LAST - PMC_EV_K7_FIRST + 1; + ev = k7_event_table; + count = PMC_EVENT_TABLE_SIZE(k7); break; case PMC_CLASS_K8: - ev = &pmc_event_table[PMC_EV_K8_FIRST]; - count = PMC_EV_K8_LAST - PMC_EV_K8_FIRST + 1; + ev = k8_event_table; + count = PMC_EVENT_TABLE_SIZE(k8); + break; + case PMC_CLASS_P4: + ev = p4_event_table; + count = PMC_EVENT_TABLE_SIZE(p4); break; case PMC_CLASS_P5: - ev = &pmc_event_table[PMC_EV_P5_FIRST]; - count = PMC_EV_P5_LAST - PMC_EV_P5_FIRST + 1; + ev = p5_event_table; + count = PMC_EVENT_TABLE_SIZE(p5); break; case PMC_CLASS_P6: - ev = &pmc_event_table[PMC_EV_P6_FIRST]; - count = PMC_EV_P6_LAST - PMC_EV_P6_FIRST + 1; - break; - case PMC_CLASS_P4: - ev = &pmc_event_table[PMC_EV_P4_FIRST]; - count = PMC_EV_P4_LAST - PMC_EV_P4_FIRST + 1; + ev = p6_event_table; + count = PMC_EVENT_TABLE_SIZE(p6); break; default: errno = EINVAL; @@ -1937,33 +2095,35 @@ pmc_init(void) for (n = 0; n < cpu_info.pm_nclass; n++) cpu_info.pm_classes[n] = op_cpu_info.pm_classes[n]; - /* set parser pointer */ +#define PMC_MDEP_INIT(C) do { \ + pmc_mdep_event_aliases = C##_aliases; \ + pmc_mdep_class_list = C##_pmc_classes; \ + pmc_mdep_class_list_size = \ + PMC_TABLE_SIZE(C##_pmc_classes); \ + } while (0) + + /* Configure the event name parser. */ switch (cpu_info.pm_cputype) { #if defined(__i386__) case PMC_CPU_AMD_K7: - pmc_mdep_event_aliases = k7_aliases; - pmc_mdep_allocate_pmc = k7_allocate_pmc; + PMC_MDEP_INIT(k7); break; case PMC_CPU_INTEL_P5: - pmc_mdep_event_aliases = p5_aliases; - pmc_mdep_allocate_pmc = p5_allocate_pmc; + PMC_MDEP_INIT(p5); break; case PMC_CPU_INTEL_P6: /* P6 ... Pentium M CPUs have */ case PMC_CPU_INTEL_PII: /* similar PMCs. */ case PMC_CPU_INTEL_PIII: case PMC_CPU_INTEL_PM: - pmc_mdep_event_aliases = p6_aliases; - pmc_mdep_allocate_pmc = p6_allocate_pmc; + PMC_MDEP_INIT(p6); break; #endif #if defined(__amd64__) || defined(__i386__) - case PMC_CPU_INTEL_PIV: - pmc_mdep_event_aliases = p4_aliases; - pmc_mdep_allocate_pmc = p4_allocate_pmc; - break; case PMC_CPU_AMD_K8: - pmc_mdep_event_aliases = k8_aliases; - pmc_mdep_allocate_pmc = k8_allocate_pmc; + PMC_MDEP_INIT(k8); + break; + case PMC_CPU_INTEL_PIV: + PMC_MDEP_INIT(p4); break; #endif @@ -2013,9 +2173,12 @@ pmc_name_of_class(enum pmc_class pc) const char * pmc_name_of_cputype(enum pmc_cputype cp) { - if ((int) cp >= PMC_CPU_FIRST && - cp <= PMC_CPU_LAST) - return (pmc_cputype_names[cp]); + size_t n; + + for (n = 0; n < PMC_TABLE_SIZE(pmc_cputype_names); n++) + if (cp == pmc_cputype_names[n].pm_cputype) + return (pmc_cputype_names[n].pm_name); + errno = EINVAL; return (NULL); } @@ -2034,9 +2197,32 @@ pmc_name_of_disposition(enum pmc_disp pd const char * pmc_name_of_event(enum pmc_event pe) { - if ((int) pe >= PMC_EVENT_FIRST && - pe <= PMC_EVENT_LAST) - return (pmc_event_table[pe].pm_ev_name); + const struct pmc_event_descr *ev, *evfence; + + ev = evfence = NULL; + if (pe >= PMC_EV_K7_FIRST && pe <= PMC_EV_K7_LAST) { + ev = k7_event_table; + evfence = k7_event_table + PMC_EVENT_TABLE_SIZE(k7); + } else if (pe >= PMC_EV_K8_FIRST && pe <= PMC_EV_K8_LAST) { + ev = k8_event_table; + evfence = k8_event_table + PMC_EVENT_TABLE_SIZE(k8); + } else if (pe >= PMC_EV_P4_FIRST && pe <= PMC_EV_P4_LAST) { + ev = p4_event_table; + evfence = p4_event_table + PMC_EVENT_TABLE_SIZE(p4); + } else if (pe >= PMC_EV_P5_FIRST && pe <= PMC_EV_P5_LAST) { + ev = p5_event_table; + evfence = p5_event_table + PMC_EVENT_TABLE_SIZE(p5); + } else if (pe >= PMC_EV_P6_FIRST && pe <= PMC_EV_P6_LAST) { + ev = p6_event_table; + evfence = p6_event_table + PMC_EVENT_TABLE_SIZE(p6); + } else if (pe == PMC_EV_TSC_TSC) { + ev = tsc_event_table; + evfence = tsc_event_table + PMC_EVENT_TABLE_SIZE(tsc); + } + + for (; ev != evfence; ev++) + if (pe == ev->pm_ev_code) + return (ev->pm_ev_name); errno = EINVAL; return (NULL); Modified: head/sys/dev/hwpmc/pmc_events.h ============================================================================== --- head/sys/dev/hwpmc/pmc_events.h Thu Oct 9 12:56:57 2008 (r183724) +++ head/sys/dev/hwpmc/pmc_events.h Thu Oct 9 14:55:45 2008 (r183725) @@ -41,35 +41,30 @@ * Optimization Guide" [Doc#22007K, Feb 2002] */ -#define __PMC_EV_K7() \ -__PMC_EV(K7, DC_ACCESSES, k7-dc-accesses) \ -__PMC_EV(K7, DC_MISSES, k7-dc-misses) \ -__PMC_EV(K7, DC_REFILLS_FROM_L2, k7-dc-refills-from-l2) \ -__PMC_EV(K7, DC_REFILLS_FROM_SYSTEM, k7-dc-refills-from-system) \ -__PMC_EV(K7, DC_WRITEBACKS, k7-dc-writebacks) \ -__PMC_EV(K7, L1_DTLB_MISS_AND_L2_DTLB_HITS, \ - k7-l1-dtlb-miss-and-l2-dtlb-hits) \ -__PMC_EV(K7, L1_AND_L2_DTLB_MISSES, k7-l1-and-l2-dtlb-misses) \ -__PMC_EV(K7, MISALIGNED_REFERENCES, k7-misaligned-references) \ -__PMC_EV(K7, IC_FETCHES, k7-ic-fetches) \ -__PMC_EV(K7, IC_MISSES, k7-ic-misses) \ -__PMC_EV(K7, L1_ITLB_MISSES, k7-l1-itlb-misses) \ -__PMC_EV(K7, L1_L2_ITLB_MISSES, k7-l1-l2-itlb-misses) \ -__PMC_EV(K7, RETIRED_INSTRUCTIONS, k7-retired-instructions) \ -__PMC_EV(K7, RETIRED_OPS, k7-retired-ops) \ -__PMC_EV(K7, RETIRED_BRANCHES, k7-retired-branches) \ -__PMC_EV(K7, RETIRED_BRANCHES_MISPREDICTED, \ - k7-retired-branches-mispredicted) \ -__PMC_EV(K7, RETIRED_TAKEN_BRANCHES, k7-retired-taken-branches) \ -__PMC_EV(K7, RETIRED_TAKEN_BRANCHES_MISPREDICTED, \ - k7-retired-taken-branches-mispredicted) \ -__PMC_EV(K7, RETIRED_FAR_CONTROL_TRANSFERS, \ - k7-retired-far-control-transfers) \ -__PMC_EV(K7, RETIRED_RESYNC_BRANCHES, k7-retired-resync-branches) \ -__PMC_EV(K7, INTERRUPTS_MASKED_CYCLES, k7-interrupts-masked-cycles) \ -__PMC_EV(K7, INTERRUPTS_MASKED_WHILE_PENDING_CYCLES, \ - k7-interrupts-masked-while-pending-cycles) \ -__PMC_EV(K7, HARDWARE_INTERRUPTS, k7-hardware-interrupts) +#define __PMC_EV_K7() \ +__PMC_EV(K7, DC_ACCESSES) \ +__PMC_EV(K7, DC_MISSES) \ +__PMC_EV(K7, DC_REFILLS_FROM_L2) \ +__PMC_EV(K7, DC_REFILLS_FROM_SYSTEM) \ +__PMC_EV(K7, DC_WRITEBACKS) \ +__PMC_EV(K7, L1_DTLB_MISS_AND_L2_DTLB_HITS) \ +__PMC_EV(K7, L1_AND_L2_DTLB_MISSES) \ +__PMC_EV(K7, MISALIGNED_REFERENCES) \ +__PMC_EV(K7, IC_FETCHES) \ +__PMC_EV(K7, IC_MISSES) \ +__PMC_EV(K7, L1_ITLB_MISSES) \ +__PMC_EV(K7, L1_L2_ITLB_MISSES) \ +__PMC_EV(K7, RETIRED_INSTRUCTIONS) \ +__PMC_EV(K7, RETIRED_OPS) \ +__PMC_EV(K7, RETIRED_BRANCHES) \ +__PMC_EV(K7, RETIRED_BRANCHES_MISPREDICTED) \ +__PMC_EV(K7, RETIRED_TAKEN_BRANCHES) \ +__PMC_EV(K7, RETIRED_TAKEN_BRANCHES_MISPREDICTED) \ +__PMC_EV(K7, RETIRED_FAR_CONTROL_TRANSFERS) \ +__PMC_EV(K7, RETIRED_RESYNC_BRANCHES) \ +__PMC_EV(K7, INTERRUPTS_MASKED_CYCLES) \ +__PMC_EV(K7, INTERRUPTS_MASKED_WHILE_PENDING_CYCLES) \ +__PMC_EV(K7, HARDWARE_INTERRUPTS) #define PMC_EV_K7_FIRST PMC_EV_K7_DC_ACCESSES #define PMC_EV_K7_LAST PMC_EV_K7_HARDWARE_INTERRUPTS @@ -79,169 +74,165 @@ __PMC_EV(K7, HARDWARE_INTERRUPTS, k7-har * Developer's Manual, Volume 3: System Programming Guide" [245472-012] */ -#define __PMC_EV_P4() \ -__PMC_EV(P4, TC_DELIVER_MODE, p4-tc-deliver-mode) \ -__PMC_EV(P4, BPU_FETCH_REQUEST, p4-bpu-fetch-request) \ -__PMC_EV(P4, ITLB_REFERENCE, p4-itlb-reference) \ -__PMC_EV(P4, MEMORY_CANCEL, p4-memory-cancel) \ -__PMC_EV(P4, MEMORY_COMPLETE, p4-memory-complete) \ -__PMC_EV(P4, LOAD_PORT_REPLAY, p4-load-port-replay) \ -__PMC_EV(P4, STORE_PORT_REPLAY, p4-store-port-replay) \ -__PMC_EV(P4, MOB_LOAD_REPLAY, p4-mob-load-replay) \ -__PMC_EV(P4, PAGE_WALK_TYPE, p4-page-walk-type) \ -__PMC_EV(P4, BSQ_CACHE_REFERENCE, p4-bsq-cache-reference) \ -__PMC_EV(P4, IOQ_ALLOCATION, p4-ioq-allocation) \ -__PMC_EV(P4, IOQ_ACTIVE_ENTRIES, p4-ioq-active-entries) \ -__PMC_EV(P4, FSB_DATA_ACTIVITY, p4-fsb-data-activity) \ -__PMC_EV(P4, BSQ_ALLOCATION, p4-bsq-allocation) \ -__PMC_EV(P4, BSQ_ACTIVE_ENTRIES, p4-bsq-active-entries) \ -__PMC_EV(P4, SSE_INPUT_ASSIST, p4-sse-input-assist) \ -__PMC_EV(P4, PACKED_SP_UOP, p4-packed-sp-uop) \ -__PMC_EV(P4, PACKED_DP_UOP, p4-packed-dp-uop) \ -__PMC_EV(P4, SCALAR_SP_UOP, p4-scalar-sp-uop) \ -__PMC_EV(P4, SCALAR_DP_UOP, p4-scalar-dp-uop) \ -__PMC_EV(P4, 64BIT_MMX_UOP, p4-64bit-mmx-uop) \ -__PMC_EV(P4, 128BIT_MMX_UOP, p4-128bit-mmx-uop) \ -__PMC_EV(P4, X87_FP_UOP, p4-x87-fp-uop) \ -__PMC_EV(P4, X87_SIMD_MOVES_UOP, p4-x87-simd-moves-uop) \ -__PMC_EV(P4, GLOBAL_POWER_EVENTS, p4-global-power-events) \ -__PMC_EV(P4, TC_MS_XFER, p4-tc-ms-xfer) \ -__PMC_EV(P4, UOP_QUEUE_WRITES, p4-uop-queue-writes) \ -__PMC_EV(P4, RETIRED_MISPRED_BRANCH_TYPE, \ - p4-retired-mispred-branch-type) \ -__PMC_EV(P4, RETIRED_BRANCH_TYPE, p4-retired-branch-type) \ -__PMC_EV(P4, RESOURCE_STALL, p4-resource-stall) \ -__PMC_EV(P4, WC_BUFFER, p4-wc-buffer) \ -__PMC_EV(P4, B2B_CYCLES, p4-b2b-cycles) \ -__PMC_EV(P4, BNR, p4-bnr) \ -__PMC_EV(P4, SNOOP, p4-snoop) \ -__PMC_EV(P4, RESPONSE, p4-response) \ -__PMC_EV(P4, FRONT_END_EVENT, p4-front-end-event) \ -__PMC_EV(P4, EXECUTION_EVENT, p4-execution-event) \ -__PMC_EV(P4, REPLAY_EVENT, p4-replay-event) \ -__PMC_EV(P4, INSTR_RETIRED, p4-instr-retired) \ -__PMC_EV(P4, UOPS_RETIRED, p4-uops-retired) \ -__PMC_EV(P4, UOP_TYPE, p4-uop-type) \ -__PMC_EV(P4, BRANCH_RETIRED, p4-branch-retired) \ -__PMC_EV(P4, MISPRED_BRANCH_RETIRED, p4-mispred-branch-retired) \ -__PMC_EV(P4, X87_ASSIST, p4-x87-assist) \ -__PMC_EV(P4, MACHINE_CLEAR, p4-machine-clear) +#define __PMC_EV_P4() \ +__PMC_EV(P4, TC_DELIVER_MODE) \ +__PMC_EV(P4, BPU_FETCH_REQUEST) \ +__PMC_EV(P4, ITLB_REFERENCE) \ +__PMC_EV(P4, MEMORY_CANCEL) \ +__PMC_EV(P4, MEMORY_COMPLETE) \ +__PMC_EV(P4, LOAD_PORT_REPLAY) \ +__PMC_EV(P4, STORE_PORT_REPLAY) \ +__PMC_EV(P4, MOB_LOAD_REPLAY) \ +__PMC_EV(P4, PAGE_WALK_TYPE) \ +__PMC_EV(P4, BSQ_CACHE_REFERENCE) \ +__PMC_EV(P4, IOQ_ALLOCATION) \ +__PMC_EV(P4, IOQ_ACTIVE_ENTRIES) \ +__PMC_EV(P4, FSB_DATA_ACTIVITY) \ +__PMC_EV(P4, BSQ_ALLOCATION) \ +__PMC_EV(P4, BSQ_ACTIVE_ENTRIES) \ +__PMC_EV(P4, SSE_INPUT_ASSIST) \ +__PMC_EV(P4, PACKED_SP_UOP) \ +__PMC_EV(P4, PACKED_DP_UOP) \ +__PMC_EV(P4, SCALAR_SP_UOP) \ +__PMC_EV(P4, SCALAR_DP_UOP) \ +__PMC_EV(P4, 64BIT_MMX_UOP) \ +__PMC_EV(P4, 128BIT_MMX_UOP) \ +__PMC_EV(P4, X87_FP_UOP) \ +__PMC_EV(P4, X87_SIMD_MOVES_UOP) \ +__PMC_EV(P4, GLOBAL_POWER_EVENTS) \ +__PMC_EV(P4, TC_MS_XFER) \ +__PMC_EV(P4, UOP_QUEUE_WRITES) \ +__PMC_EV(P4, RETIRED_MISPRED_BRANCH_TYPE) \ +__PMC_EV(P4, RETIRED_BRANCH_TYPE) \ +__PMC_EV(P4, RESOURCE_STALL) \ +__PMC_EV(P4, WC_BUFFER) \ +__PMC_EV(P4, B2B_CYCLES) \ +__PMC_EV(P4, BNR) \ +__PMC_EV(P4, SNOOP) \ +__PMC_EV(P4, RESPONSE) \ +__PMC_EV(P4, FRONT_END_EVENT) \ +__PMC_EV(P4, EXECUTION_EVENT) \ +__PMC_EV(P4, REPLAY_EVENT) \ +__PMC_EV(P4, INSTR_RETIRED) \ +__PMC_EV(P4, UOPS_RETIRED) \ +__PMC_EV(P4, UOP_TYPE) \ +__PMC_EV(P4, BRANCH_RETIRED) \ +__PMC_EV(P4, MISPRED_BRANCH_RETIRED) \ +__PMC_EV(P4, X87_ASSIST) \ +__PMC_EV(P4, MACHINE_CLEAR) #define PMC_EV_P4_FIRST PMC_EV_P4_TC_DELIVER_MODE #define PMC_EV_P4_LAST PMC_EV_P4_MACHINE_CLEAR /* Intel Pentium Pro, P-II, P-III and Pentium-M style events */ -#define __PMC_EV_P6() \ -__PMC_EV(P6, DATA_MEM_REFS, p6-data-mem-refs) \ -__PMC_EV(P6, DCU_LINES_IN, p6-dcu-lines-in) \ -__PMC_EV(P6, DCU_M_LINES_IN, p6-dcu-m-lines-in) \ -__PMC_EV(P6, DCU_M_LINES_OUT, p6-dcu-m-lines-out) \ -__PMC_EV(P6, DCU_MISS_OUTSTANDING, p6-dcu-miss-outstanding) \ -__PMC_EV(P6, IFU_FETCH, p6-ifu-ifetch) \ -__PMC_EV(P6, IFU_FETCH_MISS, p6-ifu-ifetch-miss) \ -__PMC_EV(P6, ITLB_MISS, p6-itlb-miss) \ -__PMC_EV(P6, IFU_MEM_STALL, p6-ifu-mem-stall) \ -__PMC_EV(P6, ILD_STALL, p6-ild-stall) \ -__PMC_EV(P6, L2_IFETCH, p6-l2-ifetch) \ -__PMC_EV(P6, L2_LD, p6-l2-ld) \ -__PMC_EV(P6, L2_ST, p6-l2-st) \ -__PMC_EV(P6, L2_LINES_IN, p6-l2-lines-in) \ -__PMC_EV(P6, L2_LINES_OUT, p6-l2-lines-out) \ -__PMC_EV(P6, L2_M_LINES_INM, p6-l2-m-lines-inm) \ -__PMC_EV(P6, L2_M_LINES_OUTM, p6-l2-m-lines-outm) \ -__PMC_EV(P6, L2_RQSTS, p6-l2-rqsts) \ -__PMC_EV(P6, L2_ADS, p6-l2-ads) \ -__PMC_EV(P6, L2_DBUS_BUSY, p6-l2-dbus-busy) \ -__PMC_EV(P6, L2_DBUS_BUSY_RD, p6-l2-dbus-busy-rd) \ -__PMC_EV(P6, BUS_DRDY_CLOCKS, p6-bus-drdy-clocks) \ -__PMC_EV(P6, BUS_LOCK_CLOCKS, p6-bus-lock-clocks) \ -__PMC_EV(P6, BUS_REQ_OUTSTANDING, p6-bus-req-outstanding) \ -__PMC_EV(P6, BUS_TRAN_BRD, p6-bus-tran-brd) \ -__PMC_EV(P6, BUS_TRAN_RFO, p6-bus-tran-rfo) \ -__PMC_EV(P6, BUS_TRANS_WB, p6-bus-trans-wb) \ -__PMC_EV(P6, BUS_TRAN_IFETCH, p6-bus-tran-ifetch) \ -__PMC_EV(P6, BUS_TRAN_INVAL, p6-bus-tran-inval) \ -__PMC_EV(P6, BUS_TRAN_PWR, p6-bus-tran-pwr) \ -__PMC_EV(P6, BUS_TRANS_P, p6-bus-trans-p) \ -__PMC_EV(P6, BUS_TRANS_IO, p6-bus-trans-io) \ -__PMC_EV(P6, BUS_TRAN_DEF, p6-bus-tran-def) \ -__PMC_EV(P6, BUS_TRAN_BURST, p6-bus-tran-burst) \ -__PMC_EV(P6, BUS_TRAN_ANY, p6-bus-tran-any) \ -__PMC_EV(P6, BUS_TRAN_MEM, p6-bus-tran-mem) \ -__PMC_EV(P6, BUS_DATA_RCV, p6-bus-data-rcv) \ -__PMC_EV(P6, BUS_BNR_DRV, p6-bus-bnr-drv) \ -__PMC_EV(P6, BUS_HIT_DRV, p6-bus-hit-drv) \ -__PMC_EV(P6, BUS_HITM_DRV, p6-bus-hitm-drv) \ -__PMC_EV(P6, BUS_SNOOP_STALL, p6-bus-snoop-stall) \ -__PMC_EV(P6, FLOPS, p6-flops) \ -__PMC_EV(P6, FP_COMPS_OPS_EXE, p6-fp-comps-ops-exe) \ -__PMC_EV(P6, FP_ASSIST, p6-fp-assist) \ -__PMC_EV(P6, MUL, p6-mul) \ -__PMC_EV(P6, DIV, p6-div) \ -__PMC_EV(P6, CYCLES_DIV_BUSY, p6-cycles-div-busy) \ -__PMC_EV(P6, LD_BLOCKS, p6-ld-blocks) \ -__PMC_EV(P6, SB_DRAINS, p6-sb-drains) \ -__PMC_EV(P6, MISALIGN_MEM_REF, p6-misalign-mem-ref) \ -__PMC_EV(P6, EMON_KNI_PREF_DISPATCHED, p6-emon-kni-pref-dispatched) \ -__PMC_EV(P6, EMON_KNI_PREF_MISS, p6-emon-kni-pref-miss) \ -__PMC_EV(P6, INST_RETIRED, p6-inst-retired) \ -__PMC_EV(P6, UOPS_RETIRED, p6-uops-retired) \ -__PMC_EV(P6, INST_DECODED, p6-inst-decoded) \ -__PMC_EV(P6, EMON_KNI_INST_RETIRED, p6-emon-kni-inst-retired) \ -__PMC_EV(P6, EMON_KNI_COMP_INST_RET, p6-emon-kni-comp-inst-ret) \ -__PMC_EV(P6, HW_INT_RX, p6-hw-int-rx) \ -__PMC_EV(P6, CYCLES_INT_MASKED, p6-cycles-int-masked) \ -__PMC_EV(P6, CYCLES_INT_PENDING_AND_MASKED, \ - p6-cycles-int-pending-and-masked) \ -__PMC_EV(P6, BR_INST_RETIRED, p6-br-inst-retired) \ -__PMC_EV(P6, BR_MISS_PRED_RETIRED, p6-br-miss-pred-retired) \ -__PMC_EV(P6, BR_TAKEN_RETIRED, p6-br-taken-retired) \ -__PMC_EV(P6, BR_MISS_PRED_TAKEN_RET, p6-br-miss-pred-taken-ret) \ -__PMC_EV(P6, BR_INST_DECODED, p6-br-inst-decoded) \ -__PMC_EV(P6, BTB_MISSES, p6-btb-misses) \ -__PMC_EV(P6, BR_BOGUS, p6-br-bogus) \ -__PMC_EV(P6, BACLEARS, p6-baclears) \ -__PMC_EV(P6, RESOURCE_STALLS, p6-resource-stalls) \ -__PMC_EV(P6, PARTIAL_RAT_STALLS, p6-partial-rat-stalls) \ -__PMC_EV(P6, SEGMENT_REG_LOADS, p6-segment-reg-loads) \ -__PMC_EV(P6, CPU_CLK_UNHALTED, p6-cpu-clk-unhalted) \ -__PMC_EV(P6, MMX_INSTR_EXEC, p6-mmx-instr-exec) \ -__PMC_EV(P6, MMX_SAT_INSTR_EXEC, p6-mmx-sat-instr-exec) \ -__PMC_EV(P6, MMX_UOPS_EXEC, p6-mmx-uops-exec) \ -__PMC_EV(P6, MMX_INSTR_TYPE_EXEC, p6-mmx-instr-type-exec) \ -__PMC_EV(P6, FP_MMX_TRANS, p6-fp-mmx-trans) \ -__PMC_EV(P6, MMX_ASSIST, p6-mmx-assist) \ -__PMC_EV(P6, MMX_INSTR_RET, p6-mmx-instr-ret) \ -__PMC_EV(P6, SEG_RENAME_STALLS, p6-seg-rename-stalls) \ -__PMC_EV(P6, SEG_REG_RENAMES, p6-seg-reg-renames) \ -__PMC_EV(P6, RET_SEG_RENAMES, p6-ret-seg-renames) \ -__PMC_EV(P6, EMON_EST_TRANS, p6-emon-est-trans) \ -__PMC_EV(P6, EMON_THERMAL_TRIP, p6-emon-thermal-trip) \ -__PMC_EV(P6, BR_INST_EXEC, p6-br-inst-exec) \ -__PMC_EV(P6, BR_MISSP_EXEC, p6-br-missp-exec) \ -__PMC_EV(P6, BR_BAC_MISSP_EXEC, p6-br-bac-missp-exec) \ -__PMC_EV(P6, BR_CND_EXEC, p6-br-cnd-exec) \ -__PMC_EV(P6, BR_CND_MISSP_EXEC, p6-br-cnd-missp-exec) \ -__PMC_EV(P6, BR_IND_EXEC, p6-br-ind-exec) \ -__PMC_EV(P6, BR_IND_MISSP_EXEC, p6-br-ind-missp-exec) \ -__PMC_EV(P6, BR_RET_EXEC, p6-br-ret-exec) \ -__PMC_EV(P6, BR_RET_MISSP_EXEC, p6-br-ret-missp-exec) \ -__PMC_EV(P6, BR_RET_BAC_MISSP_EXEC, p6-br-ret-bac-missp-exec) \ -__PMC_EV(P6, BR_CALL_EXEC, p6-br-call-exec) \ -__PMC_EV(P6, BR_CALL_MISSP_EXEC, p6-br-call-missp-exec) \ -__PMC_EV(P6, BR_IND_CALL_EXEC, p6-br-ind-call-exec) \ -__PMC_EV(P6, EMON_SIMD_INSTR_RETIRED, p6-emon-simd-instr-retired) \ -__PMC_EV(P6, EMON_SYNCH_UOPS, p6-emon-synch-uops) \ -__PMC_EV(P6, EMON_ESP_UOPS, p6-emon-esp-uops) \ -__PMC_EV(P6, EMON_FUSED_UOPS_RET, p6-emon-fused-uops-ret) \ -__PMC_EV(P6, EMON_UNFUSION, p6-emon-unfusion) \ -__PMC_EV(P6, EMON_PREF_RQSTS_UP, p6-emon-pref-rqsts-up) \ -__PMC_EV(P6, EMON_PREF_RQSTS_DN, p6-emon-pref-rqsts-dn) \ -__PMC_EV(P6, EMON_SSE_SSE2_INST_RETIRED, \ - p6-emon-sse-sse2-inst-retired) \ -__PMC_EV(P6, EMON_SSE_SSE2_COMP_INST_RETIRED, \ - p6-emon-sse-sse2-comp-inst-retired) +#define __PMC_EV_P6() \ +__PMC_EV(P6, DATA_MEM_REFS) \ +__PMC_EV(P6, DCU_LINES_IN) \ +__PMC_EV(P6, DCU_M_LINES_IN) \ +__PMC_EV(P6, DCU_M_LINES_OUT) \ +__PMC_EV(P6, DCU_MISS_OUTSTANDING) \ +__PMC_EV(P6, IFU_FETCH) \ +__PMC_EV(P6, IFU_FETCH_MISS) \ +__PMC_EV(P6, ITLB_MISS) \ +__PMC_EV(P6, IFU_MEM_STALL) \ +__PMC_EV(P6, ILD_STALL) \ +__PMC_EV(P6, L2_IFETCH) \ +__PMC_EV(P6, L2_LD) \ +__PMC_EV(P6, L2_ST) \ +__PMC_EV(P6, L2_LINES_IN) \ +__PMC_EV(P6, L2_LINES_OUT) \ +__PMC_EV(P6, L2_M_LINES_INM) \ +__PMC_EV(P6, L2_M_LINES_OUTM) \ +__PMC_EV(P6, L2_RQSTS) \ +__PMC_EV(P6, L2_ADS) \ +__PMC_EV(P6, L2_DBUS_BUSY) \ +__PMC_EV(P6, L2_DBUS_BUSY_RD) \ +__PMC_EV(P6, BUS_DRDY_CLOCKS) \ +__PMC_EV(P6, BUS_LOCK_CLOCKS) \ +__PMC_EV(P6, BUS_REQ_OUTSTANDING) \ +__PMC_EV(P6, BUS_TRAN_BRD) \ +__PMC_EV(P6, BUS_TRAN_RFO) \ +__PMC_EV(P6, BUS_TRANS_WB) \ +__PMC_EV(P6, BUS_TRAN_IFETCH) \ +__PMC_EV(P6, BUS_TRAN_INVAL) \ +__PMC_EV(P6, BUS_TRAN_PWR) \ +__PMC_EV(P6, BUS_TRANS_P) \ +__PMC_EV(P6, BUS_TRANS_IO) \ +__PMC_EV(P6, BUS_TRAN_DEF) \ +__PMC_EV(P6, BUS_TRAN_BURST) \ +__PMC_EV(P6, BUS_TRAN_ANY) \ +__PMC_EV(P6, BUS_TRAN_MEM) \ +__PMC_EV(P6, BUS_DATA_RCV) \ +__PMC_EV(P6, BUS_BNR_DRV) \ +__PMC_EV(P6, BUS_HIT_DRV) \ +__PMC_EV(P6, BUS_HITM_DRV) \ +__PMC_EV(P6, BUS_SNOOP_STALL) \ +__PMC_EV(P6, FLOPS) \ +__PMC_EV(P6, FP_COMPS_OPS_EXE) \ +__PMC_EV(P6, FP_ASSIST) \ +__PMC_EV(P6, MUL) \ +__PMC_EV(P6, DIV) \ +__PMC_EV(P6, CYCLES_DIV_BUSY) \ +__PMC_EV(P6, LD_BLOCKS) \ +__PMC_EV(P6, SB_DRAINS) \ +__PMC_EV(P6, MISALIGN_MEM_REF) \ +__PMC_EV(P6, EMON_KNI_PREF_DISPATCHED) \ +__PMC_EV(P6, EMON_KNI_PREF_MISS) \ +__PMC_EV(P6, INST_RETIRED) \ +__PMC_EV(P6, UOPS_RETIRED) \ +__PMC_EV(P6, INST_DECODED) \ +__PMC_EV(P6, EMON_KNI_INST_RETIRED) \ +__PMC_EV(P6, EMON_KNI_COMP_INST_RET) \ +__PMC_EV(P6, HW_INT_RX) \ +__PMC_EV(P6, CYCLES_INT_MASKED) \ +__PMC_EV(P6, CYCLES_INT_PENDING_AND_MASKED) \ +__PMC_EV(P6, BR_INST_RETIRED) \ +__PMC_EV(P6, BR_MISS_PRED_RETIRED) \ +__PMC_EV(P6, BR_TAKEN_RETIRED) \ +__PMC_EV(P6, BR_MISS_PRED_TAKEN_RET) \ +__PMC_EV(P6, BR_INST_DECODED) \ +__PMC_EV(P6, BTB_MISSES) \ +__PMC_EV(P6, BR_BOGUS) \ +__PMC_EV(P6, BACLEARS) \ +__PMC_EV(P6, RESOURCE_STALLS) \ +__PMC_EV(P6, PARTIAL_RAT_STALLS) \ +__PMC_EV(P6, SEGMENT_REG_LOADS) \ +__PMC_EV(P6, CPU_CLK_UNHALTED) \ +__PMC_EV(P6, MMX_INSTR_EXEC) \ +__PMC_EV(P6, MMX_SAT_INSTR_EXEC) \ +__PMC_EV(P6, MMX_UOPS_EXEC) \ +__PMC_EV(P6, MMX_INSTR_TYPE_EXEC) \ +__PMC_EV(P6, FP_MMX_TRANS) \ +__PMC_EV(P6, MMX_ASSIST) \ +__PMC_EV(P6, MMX_INSTR_RET) \ +__PMC_EV(P6, SEG_RENAME_STALLS) \ +__PMC_EV(P6, SEG_REG_RENAMES) \ +__PMC_EV(P6, RET_SEG_RENAMES) \ +__PMC_EV(P6, EMON_EST_TRANS) \ +__PMC_EV(P6, EMON_THERMAL_TRIP) \ +__PMC_EV(P6, BR_INST_EXEC) \ +__PMC_EV(P6, BR_MISSP_EXEC) \ +__PMC_EV(P6, BR_BAC_MISSP_EXEC) \ +__PMC_EV(P6, BR_CND_EXEC) \ +__PMC_EV(P6, BR_CND_MISSP_EXEC) \ +__PMC_EV(P6, BR_IND_EXEC) \ +__PMC_EV(P6, BR_IND_MISSP_EXEC) \ +__PMC_EV(P6, BR_RET_EXEC) \ +__PMC_EV(P6, BR_RET_MISSP_EXEC) \ +__PMC_EV(P6, BR_RET_BAC_MISSP_EXEC) \ +__PMC_EV(P6, BR_CALL_EXEC) \ +__PMC_EV(P6, BR_CALL_MISSP_EXEC) \ +__PMC_EV(P6, BR_IND_CALL_EXEC) \ +__PMC_EV(P6, EMON_SIMD_INSTR_RETIRED) \ +__PMC_EV(P6, EMON_SYNCH_UOPS) \ +__PMC_EV(P6, EMON_ESP_UOPS) \ +__PMC_EV(P6, EMON_FUSED_UOPS_RET) \ +__PMC_EV(P6, EMON_UNFUSION) \ +__PMC_EV(P6, EMON_PREF_RQSTS_UP) \ +__PMC_EV(P6, EMON_PREF_RQSTS_DN) \ +__PMC_EV(P6, EMON_SSE_SSE2_INST_RETIRED) \ +__PMC_EV(P6, EMON_SSE_SSE2_COMP_INST_RETIRED) #define PMC_EV_P6_FIRST PMC_EV_P6_DATA_MEM_REFS @@ -250,137 +241,86 @@ __PMC_EV(P6, EMON_SSE_SSE2_COMP_INST_RET /* AMD K8 PMCs */ #define __PMC_EV_K8() \ -__PMC_EV(K8, FP_DISPATCHED_FPU_OPS, k8-fp-dispatched-fpu-ops) \ -__PMC_EV(K8, FP_CYCLES_WITH_NO_FPU_OPS_RETIRED, \ - k8-fp-cycles-with-no-fpu-ops-retired) \ -__PMC_EV(K8, FP_DISPATCHED_FPU_FAST_FLAG_OPS, \ - k8-fp-dispatched-fpu-fast-flag-ops) \ -__PMC_EV(K8, LS_SEGMENT_REGISTER_LOAD, k8-ls-segment-register-load) \ -__PMC_EV(K8, LS_MICROARCHITECTURAL_RESYNC_BY_SELF_MODIFYING_CODE, \ - k8-ls-microarchitectural-resync-by-self-modifying-code) \ -__PMC_EV(K8, LS_MICROARCHITECTURAL_RESYNC_BY_SNOOP, \ - k8-ls-microarchitectural-resync-by-snoop) \ -__PMC_EV(K8, LS_BUFFER2_FULL, k8-ls-buffer2-full) \ -__PMC_EV(K8, LS_LOCKED_OPERATION, k8-ls-locked-operation) \ -__PMC_EV(K8, LS_MICROARCHITECTURAL_LATE_CANCEL, \ - k8-ls-microarchitectural-late-cancel) \ -__PMC_EV(K8, LS_RETIRED_CFLUSH_INSTRUCTIONS, \ - k8-ls-retired-cflush-instructions) \ *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From simon at FreeBSD.org Thu Oct 9 15:43:22 2008 From: simon at FreeBSD.org (Simon L. Nielsen) Date: Thu Oct 9 15:43:37 2008 Subject: svn commit: r183714 - in head: etc/rc.d lib/libarchive lib/libc/stdlib lib/msun/src share/man/man4 sys/dev/e1000 sys/dev/iicbus sys/dev/pcn sys/dev/sis sys/dev/ste sys/dev/tl sys/dev/wb sys/dev/xl ... In-Reply-To: <200810090225.m992PIom049355@svn.freebsd.org> References: <200810090225.m992PIom049355@svn.freebsd.org> Message-ID: <20081009154320.GA1210@arthur.nitro.dk> On 2008.10.09 02:25:18 +0000, Peter Wemm wrote: > Author: peter > Date: Thu Oct 9 02:25:18 2008 > New Revision: 183714 > URL: http://svn.freebsd.org/changeset/base/183714 > > Log: > Clean out some empty mergeinfo records, presumably by people doing local > cp/mv operations. The full repo-relative URL should be specified for the > source in these cases. Could you elaborate on this? -- Simon L. Nielsen From olli at fromme.com Thu Oct 9 17:33:11 2008 From: olli at fromme.com (Oliver Fromme) Date: Thu Oct 9 17:33:17 2008 Subject: svn commit: r183718 - head/sbin/geom/class/part In-Reply-To: <9bbcef730810090238y8d8eb3fl200fd25371e4d69b@mail.gmail.com> Message-ID: <200810091733.m99HX8G6091779@haluter.fromme.com> Ivan Voras wrote: > 2008/10/9 Oliver Fromme : > > > PS: Ivan: I decided to implement displaying diffs, > > as you suggested. Working on it right now. It only > > stores the most recent diffs (currently 10 days). > > Thanks, this will be completely sufficient for RSS! I think it doesn't make sense to include the diffs in the RSS "feed". Currently I only plan to put the diffs on the web page. RSS/atom "feeds" are OK for little pieces of news, but not for things that can easily grow to a few megabytes. Keep in mind that feeds are polled by the client, i.e. downloaded completely each time. This is a serious design flaw. It would be much better if the client could ask for new information and only download what it doesn't already have (much like the NNTP protocol for news servers), but RSS/atom does not support this. (On a side note, another problem is that the RSS and atom standards don't provide a portable way to include
...
sections in the XML content, so it's not possible to format the diffs properly.) Best regards Oliver -- Oliver Fromme, Bunsenstr. 13, 81735 Muenchen, Germany ``We are all but compressed light'' (Albert Einstein) From n_hibma at FreeBSD.org Thu Oct 9 18:06:28 2008 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Thu Oct 9 18:06:34 2008 Subject: svn commit: r183727 - head/tools/tools/nanobsd Message-ID: <200810091806.m99I6S11068064@svn.freebsd.org> Author: n_hibma Date: Thu Oct 9 18:06:28 2008 New Revision: 183727 URL: http://svn.freebsd.org/changeset/base/183727 Log: Avoid failing if the directory already exists (when restarting at customize). MFC after: 2 days Modified: head/tools/tools/nanobsd/nanobsd.sh Modified: head/tools/tools/nanobsd/nanobsd.sh ============================================================================== --- head/tools/tools/nanobsd/nanobsd.sh Thu Oct 9 17:52:47 2008 (r183726) +++ head/tools/tools/nanobsd/nanobsd.sh Thu Oct 9 18:06:28 2008 (r183727) @@ -281,7 +281,7 @@ setup_nanobsd ( ) ( # have hardcoded paths under ${prefix}/etc are not tweakable. if [ -d usr/local/etc ] ; then ( - mkdir etc/local + mkdir -p etc/local cd usr/local/etc find . -print | cpio -dumpl ../../../etc/local cd .. From n_hibma at FreeBSD.org Thu Oct 9 19:22:01 2008 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Thu Oct 9 19:22:13 2008 Subject: svn commit: r183728 - in head/sys: dev/usb modules modules/ehci modules/ohci modules/slhci modules/uhci Message-ID: <200810091922.m99JM0F1069368@svn.freebsd.org> Author: n_hibma Date: Thu Oct 9 19:22:00 2008 New Revision: 183728 URL: http://svn.freebsd.org/changeset/base/183728 Log: Add modules for the HCI part of USB. This is convenient when having a UHCI controller in your laptop but inserting a (OHCI-based) Option Cardbus card. Added: head/sys/modules/ehci/ head/sys/modules/ehci/Makefile (contents, props changed) head/sys/modules/ohci/ head/sys/modules/ohci/Makefile (contents, props changed) head/sys/modules/uhci/ head/sys/modules/uhci/Makefile (contents, props changed) Modified: head/sys/dev/usb/ehci_pci.c head/sys/dev/usb/ohci_pci.c head/sys/dev/usb/slhci_pccard.c head/sys/dev/usb/uhci_pci.c head/sys/modules/Makefile head/sys/modules/slhci/Makefile Modified: head/sys/dev/usb/ehci_pci.c ============================================================================== --- head/sys/dev/usb/ehci_pci.c Thu Oct 9 18:06:28 2008 (r183727) +++ head/sys/dev/usb/ehci_pci.c Thu Oct 9 19:22:00 2008 (r183728) @@ -623,3 +623,4 @@ static devclass_t ehci_devclass; DRIVER_MODULE(ehci, pci, ehci_driver, ehci_devclass, 0, 0); DRIVER_MODULE(ehci, cardbus, ehci_driver, ehci_devclass, 0, 0); +MODULE_DEPEND(ehci, usb, 1, 1, 1); Modified: head/sys/dev/usb/ohci_pci.c ============================================================================== --- head/sys/dev/usb/ohci_pci.c Thu Oct 9 18:06:28 2008 (r183727) +++ head/sys/dev/usb/ohci_pci.c Thu Oct 9 19:22:00 2008 (r183728) @@ -408,3 +408,4 @@ static devclass_t ohci_devclass; DRIVER_MODULE(ohci, pci, ohci_driver, ohci_devclass, 0, 0); DRIVER_MODULE(ohci, cardbus, ohci_driver, ohci_devclass, 0, 0); +MODULE_DEPEND(ohci, usb, 1, 1, 1); Modified: head/sys/dev/usb/slhci_pccard.c ============================================================================== --- head/sys/dev/usb/slhci_pccard.c Thu Oct 9 18:06:28 2008 (r183727) +++ head/sys/dev/usb/slhci_pccard.c Thu Oct 9 19:22:00 2008 (r183728) @@ -199,6 +199,8 @@ static driver_t slhci_pccard_driver = { slhci_pccard_methods, sizeof(struct slhci_softc), }; + devclass_t slhci_devclass; -MODULE_DEPEND(slhci, usb, 1, 1, 1); + DRIVER_MODULE(slhci, pccard, slhci_pccard_driver, slhci_devclass, 0, 0); +MODULE_DEPEND(slhci, usb, 1, 1, 1); Modified: head/sys/dev/usb/uhci_pci.c ============================================================================== --- head/sys/dev/usb/uhci_pci.c Thu Oct 9 18:06:28 2008 (r183727) +++ head/sys/dev/usb/uhci_pci.c Thu Oct 9 19:22:00 2008 (r183728) @@ -515,3 +515,4 @@ static devclass_t uhci_devclass; DRIVER_MODULE(uhci, pci, uhci_driver, uhci_devclass, 0, 0); DRIVER_MODULE(uhci, cardbus, uhci_driver, uhci_devclass, 0, 0); +MODULE_DEPEND(uhci, usb, 1, 1, 1); Modified: head/sys/modules/Makefile ============================================================================== --- head/sys/modules/Makefile Thu Oct 9 18:06:28 2008 (r183727) +++ head/sys/modules/Makefile Thu Oct 9 19:22:00 2008 (r183728) @@ -79,6 +79,7 @@ SUBDIR= ${_3dfx} \ ${_dtrace} \ dummynet \ ${_ed} \ + ehci \ ${_elink} \ ${_em} \ en \ @@ -205,6 +206,7 @@ SUBDIR= ${_3dfx} \ ${_nwfs} \ ${_nxge} \ ${_opensolaris} \ + ohci \ ${_padlock} \ patm \ ${_pccard} \ @@ -241,6 +243,7 @@ SUBDIR= ${_3dfx} \ ${_scsi_low} \ sem \ sf \ + slhci \ sis \ sk \ ${_smbfs} \ @@ -280,6 +283,7 @@ SUBDIR= ${_3dfx} \ ufoma \ uftdi \ ugen \ + uhci \ uhid \ uipaq \ ukbd \ Added: head/sys/modules/ehci/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/ehci/Makefile Thu Oct 9 19:22:00 2008 (r183728) @@ -0,0 +1,13 @@ +# $FreeBSD$ + +S= ${.CURDIR}/../.. + +.PATH: $S/dev/usb $S/pci + +KMOD= ehci +SRCS= bus_if.h device_if.h \ + opt_usb.h \ + ehci_pci.c ehci.c ehcireg.h ehcivar.h \ + pci_if.h + +.include Added: head/sys/modules/ohci/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/ohci/Makefile Thu Oct 9 19:22:00 2008 (r183728) @@ -0,0 +1,13 @@ +# $FreeBSD$ + +S= ${.CURDIR}/../.. + +.PATH: $S/dev/usb $S/pci + +KMOD= ohci +SRCS= bus_if.h device_if.h \ + opt_usb.h \ + ohci_pci.c ohci.c ohcireg.h ohcivar.h \ + pci_if.h + +.include Modified: head/sys/modules/slhci/Makefile ============================================================================== --- head/sys/modules/slhci/Makefile Thu Oct 9 18:06:28 2008 (r183727) +++ head/sys/modules/slhci/Makefile Thu Oct 9 19:22:00 2008 (r183728) @@ -5,6 +5,8 @@ KMOD= slhci SRCS= sl811hs.c slhci_pccard.c -SRCS+= opt_slhci.h opt_usb.h device_if.h bus_if.h usbdevs.h card_if.h power_if.h pccarddevs.h +SRCS+= bus_if.h device_if.h card_if.h power_if.h \ + usbdevs.h pccarddevs.h \ + opt_slhci.h opt_usb.h \ .include Added: head/sys/modules/uhci/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/uhci/Makefile Thu Oct 9 19:22:00 2008 (r183728) @@ -0,0 +1,13 @@ +# $FreeBSD$ + +S= ${.CURDIR}/../.. + +.PATH: $S/dev/usb $S/pci + +KMOD= uhci +SRCS= bus_if.h device_if.h \ + opt_usb.h \ + uhci_pci.c uhci.c uhcireg.h uhcivar.h \ + pci_if.h + +.include From imp at FreeBSD.org Thu Oct 9 19:47:29 2008 From: imp at FreeBSD.org (Warner Losh) Date: Thu Oct 9 19:47:46 2008 Subject: svn commit: r183729 - head/sys/dev/mmc Message-ID: <200810091947.m99JlTPu069919@svn.freebsd.org> Author: imp Date: Thu Oct 9 19:47:28 2008 New Revision: 183729 URL: http://svn.freebsd.org/changeset/base/183729 Log: o Use seprate routines to decode cid and csd for sd and mmc cards. All they have in common right now is a memset. This saves a parameter to these routines, as well as a level of indentation. o Make mmc_get_bits a little clearer... It really only works on 128-bit registers right now. Modified: head/sys/dev/mmc/mmc.c Modified: head/sys/dev/mmc/mmc.c ============================================================================== --- head/sys/dev/mmc/mmc.c Thu Oct 9 19:22:00 2008 (r183728) +++ head/sys/dev/mmc/mmc.c Thu Oct 9 19:47:28 2008 (r183729) @@ -718,7 +718,8 @@ mmc_test_bus_width(struct mmc_softc *sc) static uint32_t mmc_get_bits(uint32_t *bits, int start, int size) { - const int i = 3 - (start / 32); + const int bit_len = 128; + const int i = (bit_len / 32) - (start / 32) - 1; const int shift = start & 31; uint32_t retval = bits[i] >> shift; if (size + shift > 32) @@ -727,31 +728,37 @@ mmc_get_bits(uint32_t *bits, int start, } static void -mmc_decode_cid(int is_sd, uint32_t *raw_cid, struct mmc_cid *cid) +mmc_decode_cid_sd(uint32_t *raw_cid, struct mmc_cid *cid) { int i; + /* There's no version info, so we take it on faith */ memset(cid, 0, sizeof(*cid)); - if (is_sd) { - /* There's no version info, so we take it on faith */ - cid->mid = mmc_get_bits(raw_cid, 120, 8); - cid->oid = mmc_get_bits(raw_cid, 104, 16); - for (i = 0; i < 5; i++) - cid->pnm[i] = mmc_get_bits(raw_cid, 96 - i * 8, 8); - cid->prv = mmc_get_bits(raw_cid, 56, 8); - cid->psn = mmc_get_bits(raw_cid, 24, 32); - cid->mdt_year = mmc_get_bits(raw_cid, 12, 8) + 2001; - cid->mdt_month = mmc_get_bits(raw_cid, 8, 4); - } else { - cid->mid = mmc_get_bits(raw_cid, 120, 8); - cid->oid = mmc_get_bits(raw_cid, 104, 8); - for (i = 0; i < 6; i++) - cid->pnm[i] = mmc_get_bits(raw_cid, 96 - i * 8, 8); - cid->prv = mmc_get_bits(raw_cid, 48, 8); - cid->psn = mmc_get_bits(raw_cid, 16, 32); - cid->mdt_month = mmc_get_bits(raw_cid, 12, 4); - cid->mdt_year = mmc_get_bits(raw_cid, 8, 4) + 1997; - } + cid->mid = mmc_get_bits(raw_cid, 120, 8); + cid->oid = mmc_get_bits(raw_cid, 104, 16); + for (i = 0; i < 5; i++) + cid->pnm[i] = mmc_get_bits(raw_cid, 96 - i * 8, 8); + cid->prv = mmc_get_bits(raw_cid, 56, 8); + cid->psn = mmc_get_bits(raw_cid, 24, 32); + cid->mdt_year = mmc_get_bits(raw_cid, 12, 8) + 2001; + cid->mdt_month = mmc_get_bits(raw_cid, 8, 4); +} + +static void +mmc_decode_cid_mmc(uint32_t *raw_cid, struct mmc_cid *cid) +{ + int i; + + /* There's no version info, so we take it on faith */ + memset(cid, 0, sizeof(*cid)); + cid->mid = mmc_get_bits(raw_cid, 120, 8); + cid->oid = mmc_get_bits(raw_cid, 104, 8); + for (i = 0; i < 6; i++) + cid->pnm[i] = mmc_get_bits(raw_cid, 96 - i * 8, 8); + cid->prv = mmc_get_bits(raw_cid, 48, 8); + cid->psn = mmc_get_bits(raw_cid, 16, 32); + cid->mdt_month = mmc_get_bits(raw_cid, 12, 4); + cid->mdt_year = mmc_get_bits(raw_cid, 8, 4) + 1997; } static const int exp[8] = { @@ -768,71 +775,15 @@ static const int cur_max[8] = { }; static void -mmc_decode_csd(int is_sd, uint32_t *raw_csd, struct mmc_csd *csd) +mmc_decode_csd_sd(uint32_t *raw_csd, struct mmc_csd *csd) { int v; int m; int e; memset(csd, 0, sizeof(*csd)); - if (is_sd) { - csd->csd_structure = v = mmc_get_bits(raw_csd, 126, 2); - if (v == 0) { - m = mmc_get_bits(raw_csd, 115, 4); - e = mmc_get_bits(raw_csd, 112, 3); - csd->tacc = exp[e] * mant[m] + 9 / 10; - csd->nsac = mmc_get_bits(raw_csd, 104, 8) * 100; - m = mmc_get_bits(raw_csd, 99, 4); - e = mmc_get_bits(raw_csd, 96, 3); - csd->tran_speed = exp[e] * 10000 * mant[m]; - csd->ccc = mmc_get_bits(raw_csd, 84, 12); - csd->read_bl_len = 1 << mmc_get_bits(raw_csd, 80, 4); - csd->read_bl_partial = mmc_get_bits(raw_csd, 79, 1); - csd->write_blk_misalign = mmc_get_bits(raw_csd, 78, 1); - csd->read_blk_misalign = mmc_get_bits(raw_csd, 77, 1); - csd->dsr_imp = mmc_get_bits(raw_csd, 76, 1); - csd->vdd_r_curr_min = cur_min[mmc_get_bits(raw_csd, 59, 3)]; - csd->vdd_r_curr_max = cur_max[mmc_get_bits(raw_csd, 56, 3)]; - csd->vdd_w_curr_min = cur_min[mmc_get_bits(raw_csd, 53, 3)]; - csd->vdd_w_curr_max = cur_max[mmc_get_bits(raw_csd, 50, 3)]; - m = mmc_get_bits(raw_csd, 62, 12); - e = mmc_get_bits(raw_csd, 47, 3); - csd->capacity = ((1 + m) << (e + 2)) * csd->read_bl_len; - csd->erase_blk_en = mmc_get_bits(raw_csd, 46, 1); - csd->sector_size = mmc_get_bits(raw_csd, 39, 7); - csd->wp_grp_size = mmc_get_bits(raw_csd, 32, 7); - csd->wp_grp_enable = mmc_get_bits(raw_csd, 31, 1); - csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 26, 3); - csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 22, 4); - csd->write_bl_partial = mmc_get_bits(raw_csd, 21, 1); - } else if (v == 1) { - m = mmc_get_bits(raw_csd, 115, 4); - e = mmc_get_bits(raw_csd, 112, 3); - csd->tacc = exp[e] * mant[m] + 9 / 10; - csd->nsac = mmc_get_bits(raw_csd, 104, 8) * 100; - m = mmc_get_bits(raw_csd, 99, 4); - e = mmc_get_bits(raw_csd, 96, 3); - csd->tran_speed = exp[e] * 10000 * mant[m]; - csd->ccc = mmc_get_bits(raw_csd, 84, 12); - csd->read_bl_len = 1 << mmc_get_bits(raw_csd, 80, 4); - csd->read_bl_partial = mmc_get_bits(raw_csd, 79, 1); - csd->write_blk_misalign = mmc_get_bits(raw_csd, 78, 1); - csd->read_blk_misalign = mmc_get_bits(raw_csd, 77, 1); - csd->dsr_imp = mmc_get_bits(raw_csd, 76, 1); - csd->capacity = ((uint64_t)mmc_get_bits(raw_csd, 48, 22) + 1) * - 512 * 1024; - csd->erase_blk_en = mmc_get_bits(raw_csd, 46, 1); - csd->sector_size = mmc_get_bits(raw_csd, 39, 7); - csd->wp_grp_size = mmc_get_bits(raw_csd, 32, 7); - csd->wp_grp_enable = mmc_get_bits(raw_csd, 31, 1); - csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 26, 3); - csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 22, 4); - csd->write_bl_partial = mmc_get_bits(raw_csd, 21, 1); - } else - panic("unknown SD CSD version"); - } else { - csd->csd_structure = mmc_get_bits(raw_csd, 126, 2); - csd->spec_vers = mmc_get_bits(raw_csd, 122, 4); + csd->csd_structure = v = mmc_get_bits(raw_csd, 126, 2); + if (v == 0) { m = mmc_get_bits(raw_csd, 115, 4); e = mmc_get_bits(raw_csd, 112, 3); csd->tacc = exp[e] * mant[m] + 9 / 10; @@ -853,14 +804,76 @@ mmc_decode_csd(int is_sd, uint32_t *raw_ m = mmc_get_bits(raw_csd, 62, 12); e = mmc_get_bits(raw_csd, 47, 3); csd->capacity = ((1 + m) << (e + 2)) * csd->read_bl_len; -// csd->erase_blk_en = mmc_get_bits(raw_csd, 46, 1); -// csd->sector_size = mmc_get_bits(raw_csd, 39, 7); - csd->wp_grp_size = mmc_get_bits(raw_csd, 32, 5); + csd->erase_blk_en = mmc_get_bits(raw_csd, 46, 1); + csd->sector_size = mmc_get_bits(raw_csd, 39, 7); + csd->wp_grp_size = mmc_get_bits(raw_csd, 32, 7); csd->wp_grp_enable = mmc_get_bits(raw_csd, 31, 1); csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 26, 3); csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 22, 4); csd->write_bl_partial = mmc_get_bits(raw_csd, 21, 1); - } + } else if (v == 1) { + m = mmc_get_bits(raw_csd, 115, 4); + e = mmc_get_bits(raw_csd, 112, 3); + csd->tacc = exp[e] * mant[m] + 9 / 10; + csd->nsac = mmc_get_bits(raw_csd, 104, 8) * 100; + m = mmc_get_bits(raw_csd, 99, 4); + e = mmc_get_bits(raw_csd, 96, 3); + csd->tran_speed = exp[e] * 10000 * mant[m]; + csd->ccc = mmc_get_bits(raw_csd, 84, 12); + csd->read_bl_len = 1 << mmc_get_bits(raw_csd, 80, 4); + csd->read_bl_partial = mmc_get_bits(raw_csd, 79, 1); + csd->write_blk_misalign = mmc_get_bits(raw_csd, 78, 1); + csd->read_blk_misalign = mmc_get_bits(raw_csd, 77, 1); + csd->dsr_imp = mmc_get_bits(raw_csd, 76, 1); + csd->capacity = ((uint64_t)mmc_get_bits(raw_csd, 48, 22) + 1) * + 512 * 1024; + csd->erase_blk_en = mmc_get_bits(raw_csd, 46, 1); + csd->sector_size = mmc_get_bits(raw_csd, 39, 7); + csd->wp_grp_size = mmc_get_bits(raw_csd, 32, 7); + csd->wp_grp_enable = mmc_get_bits(raw_csd, 31, 1); + csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 26, 3); + csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 22, 4); + csd->write_bl_partial = mmc_get_bits(raw_csd, 21, 1); + } else + panic("unknown SD CSD version"); +} + +static void +mmc_decode_csd_mmc(uint32_t *raw_csd, struct mmc_csd *csd) +{ + int m; + int e; + + memset(csd, 0, sizeof(*csd)); + csd->csd_structure = mmc_get_bits(raw_csd, 126, 2); + csd->spec_vers = mmc_get_bits(raw_csd, 122, 4); + m = mmc_get_bits(raw_csd, 115, 4); + e = mmc_get_bits(raw_csd, 112, 3); + csd->tacc = exp[e] * mant[m] + 9 / 10; + csd->nsac = mmc_get_bits(raw_csd, 104, 8) * 100; + m = mmc_get_bits(raw_csd, 99, 4); + e = mmc_get_bits(raw_csd, 96, 3); + csd->tran_speed = exp[e] * 10000 * mant[m]; + csd->ccc = mmc_get_bits(raw_csd, 84, 12); + csd->read_bl_len = 1 << mmc_get_bits(raw_csd, 80, 4); + csd->read_bl_partial = mmc_get_bits(raw_csd, 79, 1); + csd->write_blk_misalign = mmc_get_bits(raw_csd, 78, 1); + csd->read_blk_misalign = mmc_get_bits(raw_csd, 77, 1); + csd->dsr_imp = mmc_get_bits(raw_csd, 76, 1); + csd->vdd_r_curr_min = cur_min[mmc_get_bits(raw_csd, 59, 3)]; + csd->vdd_r_curr_max = cur_max[mmc_get_bits(raw_csd, 56, 3)]; + csd->vdd_w_curr_min = cur_min[mmc_get_bits(raw_csd, 53, 3)]; + csd->vdd_w_curr_max = cur_max[mmc_get_bits(raw_csd, 50, 3)]; + m = mmc_get_bits(raw_csd, 62, 12); + e = mmc_get_bits(raw_csd, 47, 3); + csd->capacity = ((1 + m) << (e + 2)) * csd->read_bl_len; +// csd->erase_blk_en = mmc_get_bits(raw_csd, 46, 1); +// csd->sector_size = mmc_get_bits(raw_csd, 39, 7); + csd->wp_grp_size = mmc_get_bits(raw_csd, 32, 5); + csd->wp_grp_enable = mmc_get_bits(raw_csd, 31, 1); + csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 26, 3); + csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 22, 4); + csd->write_bl_partial = mmc_get_bits(raw_csd, 21, 1); } static void @@ -873,7 +886,7 @@ mmc_app_decode_scr(uint32_t *raw_scr, st tmp[2] = raw_scr[0]; memset(scr, 0, sizeof(*scr)); - + scr_struct = mmc_get_bits(tmp, 60, 4); if (scr_struct != 0) { printf("Unrecognised SCR structure version %d\n", @@ -1020,12 +1033,12 @@ mmc_discover_cards(struct mmc_softc *sc) ivar->bus_width = bus_width_1; ivar->mode = mmcbr_get_mode(sc->dev); if (ivar->mode == mode_sd) { - mmc_decode_cid(1, ivar->raw_cid, &ivar->cid); + mmc_decode_cid_sd(ivar->raw_cid, &ivar->cid); mmc_send_relative_addr(sc, &resp); ivar->rca = resp >> 16; /* Get card CSD. */ mmc_send_csd(sc, ivar->rca, ivar->raw_csd); - mmc_decode_csd(1, ivar->raw_csd, &ivar->csd); + mmc_decode_csd_sd(ivar->raw_csd, &ivar->csd); if (ivar->csd.csd_structure > 0) ivar->high_cap = 1; ivar->tran_speed = ivar->csd.tran_speed; @@ -1052,12 +1065,12 @@ mmc_discover_cards(struct mmc_softc *sc) device_set_ivars(child, ivar); return; } - mmc_decode_cid(0, ivar->raw_cid, &ivar->cid); + mmc_decode_cid_mmc(ivar->raw_cid, &ivar->cid); ivar->rca = rca++; mmc_set_relative_addr(sc, ivar->rca); /* Get card CSD. */ mmc_send_csd(sc, ivar->rca, ivar->raw_csd); - mmc_decode_csd(0, ivar->raw_csd, &ivar->csd); + mmc_decode_csd_mmc(ivar->raw_csd, &ivar->csd); ivar->tran_speed = ivar->csd.tran_speed; /* Only MMC >= 4.x cards support EXT_CSD. */ if (ivar->csd.spec_vers >= 4) { From n_hibma at FreeBSD.org Thu Oct 9 20:00:18 2008 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Thu Oct 9 20:00:30 2008 Subject: svn commit: r183730 - head/sys/modules/usb Message-ID: <200810092000.m99K0H3H070265@svn.freebsd.org> Author: n_hibma Date: Thu Oct 9 20:00:17 2008 New Revision: 183730 URL: http://svn.freebsd.org/changeset/base/183730 Log: Obfuscated by other diffs while committing r183728: Remove the files for the HCI interfaces from the usb module. Modified: head/sys/modules/usb/Makefile Modified: head/sys/modules/usb/Makefile ============================================================================== --- head/sys/modules/usb/Makefile Thu Oct 9 19:47:28 2008 (r183729) +++ head/sys/modules/usb/Makefile Thu Oct 9 20:00:17 2008 (r183730) @@ -19,9 +19,4 @@ SRCS= bus_if.h device_if.h usb_if.h usb_ usbdi_util.c usbdi_util.h \ usb_ethersubr.c usbdevs.h -SRCS+= uhci_pci.c uhci.c uhcireg.h uhcivar.h -SRCS+= ohci_pci.c ohci.c ohcireg.h ohcivar.h -SRCS+= ehci_pci.c ehci.c ehcireg.h ehcivar.h -SRCS+= pci_if.h - .include From mav at FreeBSD.org Thu Oct 9 20:09:57 2008 From: mav at FreeBSD.org (Alexander Motin) Date: Thu Oct 9 20:10:03 2008 Subject: svn commit: r183731 - head/sys/dev/mmc Message-ID: <200810092009.m99K9ueD070472@svn.freebsd.org> Author: mav Date: Thu Oct 9 20:09:56 2008 New Revision: 183731 URL: http://svn.freebsd.org/changeset/base/183731 Log: Add high capacity MMC cards support. Modified: head/sys/dev/mmc/mmc.c Modified: head/sys/dev/mmc/mmc.c ============================================================================== --- head/sys/dev/mmc/mmc.c Thu Oct 9 20:00:17 2008 (r183730) +++ head/sys/dev/mmc/mmc.c Thu Oct 9 20:09:56 2008 (r183731) @@ -93,7 +93,8 @@ struct mmc_ivars { u_char read_only; /* True when the device is read-only */ u_char bus_width; /* Bus width to use */ u_char timing; /* Bus timing support */ - u_char high_cap; /* High Capacity card */ + u_char high_cap; /* High Capacity card (block addressed) */ + uint32_t sec_count; /* Card capacity in 512byte blocks */ uint32_t tran_speed; /* Max speed in normal mode */ uint32_t hs_tran_speed; /* Max speed in high speed mode */ }; @@ -1011,7 +1012,7 @@ mmc_discover_cards(struct mmc_softc *sc) { struct mmc_ivars *ivar; int err; - uint32_t resp; + uint32_t resp, sec_count; device_t child; uint16_t rca = 2; u_char switch_res[64]; @@ -1039,6 +1040,7 @@ mmc_discover_cards(struct mmc_softc *sc) /* Get card CSD. */ mmc_send_csd(sc, ivar->rca, ivar->raw_csd); mmc_decode_csd_sd(ivar->raw_csd, &ivar->csd); + ivar->sec_count = ivar->csd.capacity / MMC_SECTOR_SIZE; if (ivar->csd.csd_structure > 0) ivar->high_cap = 1; ivar->tran_speed = ivar->csd.tran_speed; @@ -1071,18 +1073,28 @@ mmc_discover_cards(struct mmc_softc *sc) /* Get card CSD. */ mmc_send_csd(sc, ivar->rca, ivar->raw_csd); mmc_decode_csd_mmc(ivar->raw_csd, &ivar->csd); + ivar->sec_count = ivar->csd.capacity / MMC_SECTOR_SIZE; ivar->tran_speed = ivar->csd.tran_speed; /* Only MMC >= 4.x cards support EXT_CSD. */ if (ivar->csd.spec_vers >= 4) { /* Card must be selected to fetch EXT_CSD. */ mmc_select_card(sc, ivar->rca); mmc_send_ext_csd(sc, ivar->raw_ext_csd); + /* Handle extended capacity from EXT_CSD */ + sec_count = ivar->raw_ext_csd[EXT_CSD_SEC_CNT] + + (ivar->raw_ext_csd[EXT_CSD_SEC_CNT + 1] << 8) + + (ivar->raw_ext_csd[EXT_CSD_SEC_CNT + 2] << 16) + + (ivar->raw_ext_csd[EXT_CSD_SEC_CNT + 3] << 24); + if (sec_count != 0) { + ivar->sec_count = sec_count; + ivar->high_cap = 1; + } /* Get card speed in high speed mode. */ ivar->timing = bus_timing_hs; - if (((uint8_t *)(ivar->raw_ext_csd))[EXT_CSD_CARD_TYPE] + if (ivar->raw_ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_52) ivar->hs_tran_speed = 52000000; - else if (((uint8_t *)(ivar->raw_ext_csd))[EXT_CSD_CARD_TYPE] + else if (ivar->raw_ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_26) ivar->hs_tran_speed = 26000000; else @@ -1234,7 +1246,7 @@ mmc_read_ivar(device_t bus, device_t chi *(int *)result = ivar->csd.dsr_imp; break; case MMC_IVAR_MEDIA_SIZE: - *(off_t *)result = ivar->csd.capacity / MMC_SECTOR_SIZE; + *(off_t *)result = ivar->sec_count; break; case MMC_IVAR_RCA: *(int *)result = ivar->rca; From thompsa at FreeBSD.org Thu Oct 9 20:43:42 2008 From: thompsa at FreeBSD.org (Andrew Thompson) Date: Thu Oct 9 20:43:53 2008 Subject: svn commit: r183733 - head/sys/libkern Message-ID: <200810092043.m99KhgVB071147@svn.freebsd.org> Author: thompsa Date: Thu Oct 9 20:43:42 2008 New Revision: 183733 URL: http://svn.freebsd.org/changeset/base/183733 Log: Prefix the static shl function with '__' like its parent function __qdivrem to avoid being picked up by the DTrace fbt provider. This is called by __udivdi3() for doing 64bit division on a 32bit arch and may be called from within the dtrace context causing a double fault. Modified: head/sys/libkern/qdivrem.c Modified: head/sys/libkern/qdivrem.c ============================================================================== --- head/sys/libkern/qdivrem.c Thu Oct 9 20:40:11 2008 (r183732) +++ head/sys/libkern/qdivrem.c Thu Oct 9 20:43:42 2008 (r183733) @@ -59,7 +59,7 @@ typedef u_long digit; * We may assume len >= 0. NOTE THAT THIS WRITES len+1 DIGITS. */ static void -shl(register digit *p, register int len, register int sh) +__shl(register digit *p, register int len, register int sh) { register int i; @@ -182,8 +182,8 @@ __qdivrem(uq, vq, arq) for (t = v[1]; t < B / 2; t <<= 1) d++; if (d > 0) { - shl(&u[0], m + n, d); /* u <<= d */ - shl(&v[1], n - 1, d); /* v <<= d */ + __shl(&u[0], m + n, d); /* u <<= d */ + __shl(&v[1], n - 1, d); /* v <<= d */ } /* * D2: j = 0. From n_hibma at FreeBSD.org Thu Oct 9 20:51:28 2008 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Thu Oct 9 20:51:34 2008 Subject: svn commit: r183734 - head/sys/dev/usb Message-ID: <200810092051.m99KpP3W071320@svn.freebsd.org> Author: n_hibma Date: Thu Oct 9 20:51:25 2008 New Revision: 183734 URL: http://svn.freebsd.org/changeset/base/183734 Log: uark/ucom: Minor code cleanup. umass; Remove duplicated code. ukbd: Fill in the arg parameter on the through call. Modified: head/sys/dev/usb/uark.c head/sys/dev/usb/ucom.c head/sys/dev/usb/ukbd.c head/sys/dev/usb/umass.c Modified: head/sys/dev/usb/uark.c ============================================================================== --- head/sys/dev/usb/uark.c Thu Oct 9 20:43:42 2008 (r183733) +++ head/sys/dev/usb/uark.c Thu Oct 9 20:51:25 2008 (r183734) @@ -185,7 +185,7 @@ uark_attach(device_t self) return 0; bad: - DPRINTF(("uftdi_attach: ATTACH ERROR\n")); + DPRINTF(("uark_attach: ATTACH ERROR\n")); ucom->sc_dying = 1; return ENXIO; } Modified: head/sys/dev/usb/ucom.c ============================================================================== --- head/sys/dev/usb/ucom.c Thu Oct 9 20:43:42 2008 (r183733) +++ head/sys/dev/usb/ucom.c Thu Oct 9 20:51:25 2008 (r183734) @@ -161,14 +161,11 @@ ucom_modevent(module_t mod, int type, vo { switch (type) { case MOD_LOAD: - break; case MOD_UNLOAD: - break; + return (0); default: return (EOPNOTSUPP); - break; } - return (0); } void Modified: head/sys/dev/usb/ukbd.c ============================================================================== --- head/sys/dev/usb/ukbd.c Thu Oct 9 20:43:42 2008 (r183733) +++ head/sys/dev/usb/ukbd.c Thu Oct 9 20:51:25 2008 (r183734) @@ -1534,5 +1534,5 @@ ukbd_driver_load(module_t mod, int what, kbd_delete_driver(&ukbd_kbd_driver); break; } - return usbd_driver_load(mod, what, 0); + return usbd_driver_load(mod, what, arg); } Modified: head/sys/dev/usb/umass.c ============================================================================== --- head/sys/dev/usb/umass.c Thu Oct 9 20:43:42 2008 (r183733) +++ head/sys/dev/usb/umass.c Thu Oct 9 20:51:25 2008 (r183734) @@ -3291,17 +3291,6 @@ umass_cam_quirk_cb(struct umass_softc *s xpt_done(ccb); } -static int -umass_driver_load(module_t mod, int what, void *arg) -{ - switch (what) { - case MOD_UNLOAD: - case MOD_LOAD: - default: - return(usbd_driver_load(mod, what, arg)); - } -} - /* * SCSI specific functions */ @@ -3541,7 +3530,7 @@ umass_atapi_transform(struct umass_softc /* (even the comment is missing) */ -DRIVER_MODULE(umass, uhub, umass_driver, umass_devclass, umass_driver_load, 0); +DRIVER_MODULE(umass, uhub, umass_driver, umass_devclass, usbd_driver_load, 0); From n_hibma at FreeBSD.org Thu Oct 9 21:25:02 2008 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Thu Oct 9 21:25:09 2008 Subject: svn commit: r183735 - in head: share/man/man4 sys/conf sys/dev/usb sys/i386/conf sys/modules sys/modules/u3g Message-ID: <200810092125.m99LP1fJ071973@svn.freebsd.org> Author: n_hibma Date: Thu Oct 9 21:25:01 2008 New Revision: 183735 URL: http://svn.freebsd.org/changeset/base/183735 Log: Say hello to the u3g driver, implementing support for 3G modems. This was located in the ubsa driver, but should be moved into a separate driver: - 3G modems provide multiple serial ports to allow AT commands while the PPP connection is up. - 3G modems do not provide baud rate or other serial port settings. - Huawei cards need specific initialisation. - ubsa is for Belkin adapters, an Linuxy choice for another device like 3G. Speeds achieved here with a weak signal at best is ~40kb/s (UMTS). No spooky STALLED messages as well. Next: Move over all entries for Sierra and Novatel cards once I have found testers, and implemented serial port enumeration for Sierra (or rather have Andrea Guzzo do it). They list all endpoints in 1 iface instead of 4 ifaces. Submitted by: aguzzo@anywi.com MFC after: 3 weeks Added: head/share/man/man4/u3g.4 (contents, props changed) head/sys/dev/usb/u3g.c (contents, props changed) head/sys/modules/u3g/ head/sys/modules/u3g/Makefile (contents, props changed) Modified: head/share/man/man4/Makefile head/sys/conf/NOTES head/sys/conf/files head/sys/dev/usb/ubsa.c head/sys/dev/usb/usbdevs head/sys/i386/conf/GENERIC head/sys/modules/Makefile Modified: head/share/man/man4/Makefile ============================================================================== --- head/share/man/man4/Makefile Thu Oct 9 20:51:25 2008 (r183734) +++ head/share/man/man4/Makefile Thu Oct 9 21:25:01 2008 (r183735) @@ -384,6 +384,7 @@ MAN= aac.4 \ twe.4 \ tx.4 \ txp.4 \ + u3g.4 \ uark.4 \ uart.4 \ ubsa.4 \ Added: head/share/man/man4/u3g.4 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man4/u3g.4 Thu Oct 9 21:25:01 2008 (r183735) @@ -0,0 +1,100 @@ +.\" +.\" Copyright (c) 2008 AnyWi Technologies +.\" All rights reserved. +.\" +.\" This code is derived from uark.c +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.\" +.\" $FreeBSD$ +.\" +.Dd October 7, 2008 +.Dt U3G 4 +.Os +.Sh NAME +.Nm u3g +.Nd USB support for 3G datacards +.Sh SYNOPSIS +To compile this driver into the kernel, +place the following lines in your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "device u3g" +.Cd "device ucom" +.Ed +.Pp +Alternatively, to load the driver as a +module at boot time, place the following line in +.Xr loader.conf 5 : +.Bd -literal -offset indent +u3g_load="YES" +.Ed +.Sh DESCRIPTION +The +.Nm +driver provides support for the multiple USB-to-serial interfaces exposed by +many 3G usb/pccard modems. +.Pp +The device is accessed through the +.Xr ucom 4 +driver which makes it behave like a +.Xr tty 4 . +.Sh HARDWARE +The +.Nm +driver supports the following adapters: +.Pp +.Bl -bullet -compact +.It +Option Globetrotter 3G Fusion (only 3G part, not WLAN) +.It +Option Globetrotter 3G Fusion Quad (only 3G part, not WLAN) +.It +Option Globetrotter 3G Quad +.It +Option Globetrotter 3G +.It +Vodafone Mobile Connect Card 3G +.It +Huawei E220 (E270?) +.It +Huawei Mobile +.El +.Pp +The supported 3G cards provide the necessary modem port for ppp, +pppd, or mpd connections as well as extra ports (depending on the specific +device) to provide other functions (diagnostic port, SIM toolkit port) +.Sh SEE ALSO +.Xr tty 4 , +.Xr ucom 4 , +.Xr usb 4 , +.Xr ubsa 4 +.Sh HISTORY +The +.Nm +driver +appeared in +.Fx 7.0 . +The +.Xr ubsa 4 +manual page was modified for +.Nm +by +.An Andrea Guzzo Aq aguzzo@anywi.com +in September 2008. +.Sh AUTHORS +The +.Nm +driver was written by +.An Andrea Guzzo Aq aguzzo@anywi.com . +Hardware for testing provided by AnyWi Technologies, Leiden, NL. Modified: head/sys/conf/NOTES ============================================================================== --- head/sys/conf/NOTES Thu Oct 9 20:51:25 2008 (r183734) +++ head/sys/conf/NOTES Thu Oct 9 21:25:01 2008 (r183735) @@ -2416,6 +2416,8 @@ device uscanner # # USB serial support device ucom +# USB support for 3G modem cards by Option, Huawei and Sierra +device u3g # USB support for Technologies ARK3116 based serial adapters device uark # USB support for Belkin F5U103 and compatible serial adapters @@ -2441,7 +2443,6 @@ device aue # ASIX Electronics AX88172 USB 2.0 ethernet driver. Used in the # LinkSys USB200M and various other adapters. - device axe # Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Thu Oct 9 20:51:25 2008 (r183734) +++ head/sys/conf/files Thu Oct 9 21:25:01 2008 (r183735) @@ -1327,6 +1327,7 @@ dev/usb/ohci_pci.c optional ohci pci dev/usb/sl811hs.c optional slhci dev/usb/slhci_pccard.c optional slhci pccard dev/usb/uark.c optional uark +dev/usb/u3g.c optional u3g dev/usb/ubsa.c optional ubsa dev/usb/ubser.c optional ubser dev/usb/ucom.c optional ucom Added: head/sys/dev/usb/u3g.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/usb/u3g.c Thu Oct 9 21:25:01 2008 (r183735) @@ -0,0 +1,330 @@ +/* + * Copyright (c) 2008 AnyWi Technologies + * Author: Andrea Guzzo + * * based on uark.c 1.1 2006/08/14 08:30:22 jsg * + * * parts from ubsa.c 183348 2008-09-25 12:00:56Z phk * + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "usbdevs.h" + +#ifdef U3G_DEBUG +#define DPRINTFN(n, x) do { if (u3gdebug > (n)) printf x; } while (0) +int u3gtebug = 0; +#else +#define DPRINTFN(n, x) +#endif +#define DPRINTF(x) DPRINTFN(0, x) + +#define U3GBUFSZ 1024 +#define U3G_MAXPORTS 4 + +struct u3g_softc { + struct ucom_softc sc_ucom[U3G_MAXPORTS];; + device_t sc_dev; + usbd_device_handle sc_udev; + u_char sc_msr; + u_char sc_lsr; + u_char numports; + + usbd_interface_handle sc_intr_iface; /* interrupt interface */ +#ifdef U3G_DEBUG + int sc_intr_number; /* interrupt number */ + usbd_pipe_handle sc_intr_pipe; /* interrupt pipe */ + u_char *sc_intr_buf; /* interrupt buffer */ +#endif + int sc_isize; +}; + +struct ucom_callback u3g_callback = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, +}; + +static const struct usb_devno u3g_devs[] = { + /* OEM: Option */ + { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3G }, + { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GQUAD }, + { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GPLUS }, + { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GTMAX36 }, + { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_VODAFONEMC3G }, + /* OEM: Huawei */ + { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_MOBILE }, + { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220 }, + + { 0, 0 } +}; + +#ifdef U3G_DEBUG +static void +u3g_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) +{ + struct u3g_softc *sc = (struct u3g_softc *)priv; + device_printf(sc->sc_dev, "INTERRUPT CALLBACK\n"); +} +#endif + +static int +u3g_huawei_reinit(usbd_device_handle dev) +{ + /* The Huawei device presents itself as a umass device with Windows + * drivers on it. After installation of the driver, it reinits into a + * 3G serial device. + */ + usb_device_request_t req; + usb_config_descriptor_t *cdesc; + + /* Get the config descriptor */ + cdesc = usbd_get_config_descriptor(dev); + if (cdesc == NULL) + return (UMATCH_NONE); + + /* One iface means umass mode, more than 1 (4 usually) means 3G mode */ + if (cdesc->bNumInterface > 1) + return (UMATCH_VENDOR_PRODUCT); + + req.bmRequestType = UT_WRITE_DEVICE; + req.bRequest = UR_SET_FEATURE; + USETW(req.wValue, UF_DEVICE_REMOTE_WAKEUP); + USETW(req.wIndex, UHF_PORT_SUSPEND); + USETW(req.wLength, 0); + + (void) usbd_do_request(dev, &req, 0); + + return UMATCH_NONE; /* mismatch; it will be gone and reappear */ +} + +static int +u3g_match(device_t self) +{ + struct usb_attach_arg *uaa = device_get_ivars(self); + + if (uaa->iface != NULL) + return (UMATCH_NONE); + + if (uaa->vendor == USB_VENDOR_HUAWEI) + return u3g_huawei_reinit(uaa->device); + + if (usb_lookup(u3g_devs, uaa->vendor, uaa->product)) + return UMATCH_VENDOR_PRODUCT; + + return UMATCH_NONE; +} + +static int +u3g_attach(device_t self) +{ + struct u3g_softc *sc = device_get_softc(self); + struct usb_attach_arg *uaa = device_get_ivars(self); + usbd_device_handle dev = uaa->device; + usbd_interface_handle iface; + usb_interface_descriptor_t *id; + usb_endpoint_descriptor_t *ed; + usbd_status error; + int i, n; + usb_config_descriptor_t *cdesc; + struct ucom_softc *ucom = NULL; + char devnamefmt[32]; + + sc->sc_dev = self; +#ifdef DEBUG + sc->sc_intr_number = -1; + sc->sc_intr_pipe = NULL; +#endif + /* Move the device into the configured state. */ + error = usbd_set_config_index(dev, 1, 1); + if (error) { + device_printf(self, "failed to set configuration: %s\n", + usbd_errstr(error)); + goto bad; + } + + /* get the config descriptor */ + cdesc = usbd_get_config_descriptor(dev); + + if (cdesc == NULL) { + device_printf(self, "failed to get configuration descriptor\n"); + goto bad; + } + + sc->sc_udev = dev; + sc->numports = (cdesc->bNumInterface <= U3G_MAXPORTS)?cdesc->bNumInterface:U3G_MAXPORTS; + for ( i = 0; i < sc->numports; i++ ) { + ucom = &sc->sc_ucom[i]; + + ucom->sc_dev = self; + ucom->sc_udev = dev; + error = usbd_device2interface_handle(dev, i, &iface); + if (error) { + device_printf(ucom->sc_dev, + "failed to get interface, err=%s\n", + usbd_errstr(error)); + ucom->sc_dying = 1; + goto bad; + } + id = usbd_get_interface_descriptor(iface); + ucom->sc_iface = iface; + + ucom->sc_bulkin_no = ucom->sc_bulkout_no = -1; + for (n = 0; n < id->bNumEndpoints; n++) { + ed = usbd_interface2endpoint_descriptor(iface, n); + if (ed == NULL) { + device_printf(ucom->sc_dev, + "could not read endpoint descriptor\n"); + goto bad; + } + if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN && + UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) + ucom->sc_bulkin_no = ed->bEndpointAddress; + else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT && + UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) + ucom->sc_bulkout_no = ed->bEndpointAddress; + } + if (ucom->sc_bulkin_no == -1 || ucom->sc_bulkout_no == -1) { + device_printf(ucom->sc_dev, "missing endpoint\n"); + goto bad; + } + ucom->sc_parent = sc; + ucom->sc_ibufsize = U3GBUFSZ; + ucom->sc_obufsize = U3GBUFSZ; + ucom->sc_ibufsizepad = U3GBUFSZ; + ucom->sc_opkthdrlen = 0; + + ucom->sc_callback = &u3g_callback; + + sprintf(devnamefmt,"U%d.%%d", device_get_unit(self)); + DPRINTF(("u3g: in=0x%x out=0x%x, devname=%s\n", + ucom->sc_bulkin_no, ucom->sc_bulkout_no, devnamefmt)); +#if __FreeBSD_version < 800000 + ucom_attach_tty(ucom, TS_CALLOUT, devnamefmt, i); +#else + ucom_attach_tty(ucom, devnamefmt, i); +#endif + } +#ifdef U3G_DEBUG + if (sc->sc_intr_number != -1 && sc->sc_intr_pipe == NULL) { + sc->sc_intr_buf = malloc(sc->sc_isize, M_USBDEV, M_WAITOK); + error = usbd_open_pipe_intr(sc->sc_intr_iface, + sc->sc_intr_number, + USBD_SHORT_XFER_OK, + &sc->sc_intr_pipe, + sc, + sc->sc_intr_buf, + sc->sc_isize, + u3g_intr, + 100); + if (error) { + device_printf(self, + "cannot open interrupt pipe (addr %d)\n", + sc->sc_intr_number); + goto bad; + } + } +#endif + device_printf(self, "configured %d serial ports (/dev/cuaU%d.X)", + sc->numports, device_get_unit(self)); + + return 0; + +bad: + DPRINTF(("u3g_attach: ATTACH ERROR\n")); + ucom->sc_dying = 1; + return ENXIO; +} + +static int +u3g_detach(device_t self) +{ + struct u3g_softc *sc = device_get_softc(self); + int rv = 0; + int i; + + DPRINTF(("u3g_detach: sc=%p\n", sc)); + + for (i = 0; i < sc->numports; i++) { + if(sc->sc_ucom[i].sc_udev) { + sc->sc_ucom[i].sc_dying = 1; + rv = ucom_detach(&sc->sc_ucom[i]); + if(rv != 0) { + device_printf(self, "Can't deallocat port %d", i); + return rv; + } + } + } + +#ifdef U3G_DEBUG + if (sc->sc_intr_pipe != NULL) { + int err = usbd_abort_pipe(sc->sc_intr_pipe); + if (err) + device_printf(self, + "abort interrupt pipe failed: %s\n", + usbd_errstr(err)); + err = usbd_close_pipe(sc->sc_intr_pipe); + if (err) + device_printf(self, + "close interrupt pipe failed: %s\n", + usbd_errstr(err)); + free(sc->sc_intr_buf, M_USBDEV); + sc->sc_intr_pipe = NULL; + } +#endif + + return 0; +} + +static device_method_t u3g_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, u3g_match), + DEVMETHOD(device_attach, u3g_attach), + DEVMETHOD(device_detach, u3g_detach), + + { 0, 0 } +}; + +static driver_t u3g_driver = { + "ucom", + u3g_methods, + sizeof (struct u3g_softc) +}; + +DRIVER_MODULE(u3g, uhub, u3g_driver, ucom_devclass, usbd_driver_load, 0); +MODULE_DEPEND(u3g, usb, 1, 1, 1); +MODULE_DEPEND(u3g, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER); Modified: head/sys/dev/usb/ubsa.c ============================================================================== --- head/sys/dev/usb/ubsa.c Thu Oct 9 20:51:25 2008 (r183734) +++ head/sys/dev/usb/ubsa.c Thu Oct 9 21:25:01 2008 (r183735) @@ -161,8 +161,6 @@ SYSCTL_INT(_hw_usb_ubsa, OID_AUTO, debug struct ubsa_softc { struct ucom_softc sc_ucom; - int sc_huawei; - int sc_iface_number; /* interface number */ usbd_interface_handle sc_intr_iface; /* interrupt interface */ @@ -228,24 +226,11 @@ static const struct ubsa_product { { USB_VENDOR_GOHUBS, USB_PRODUCT_GOHUBS_GOCOM232 }, /* Peracom */ { USB_VENDOR_PERACOM, USB_PRODUCT_PERACOM_SERIAL1 }, - /* Dell version of the Novatel 740 */ - { USB_VENDOR_DELL, USB_PRODUCT_DELL_U740 }, - /* Option Vodafone MC3G */ - { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_VODAFONEMC3G }, - /* Option GlobeTrotter 3G */ - { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3G }, - /* Option GlobeTrotter 3G QUAD */ - { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GQUAD }, - /* Option GlobeTrotter 3G+ */ - { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GPLUS }, - /* Option GlobeTrotter Max 3.6 */ - { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GTMAX36 }, - /* Huawei Mobile */ - { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_MOBILE }, - { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E270 }, + /* Merlin */ { USB_VENDOR_MERLIN, USB_PRODUCT_MERLIN_V620 }, /* Qualcomm, Inc. ZTE CDMA */ { USB_VENDOR_QUALCOMMINC, USB_PRODUCT_QUALCOMMINC_CDMA_MSM }, + /* Novatel */ { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_CDMA_MODEM }, /* Novatel Wireless Merlin ES620 */ { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_ES620 }, @@ -256,6 +241,8 @@ static const struct ubsa_product { /* Novatel Wireless Merlin U740 */ { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740 }, { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740_2 }, + /* Dell version of the Novatel 740 */ + { USB_VENDOR_DELL, USB_PRODUCT_DELL_U740 }, /* Novatel Wireless Merlin U950D */ { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U950D }, /* Novatel Wireless Merlin V620 */ @@ -341,52 +328,6 @@ MODULE_DEPEND(ubsa, usb, 1, 1, 1); MODULE_DEPEND(ubsa, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER); MODULE_VERSION(ubsa, UBSA_MODVER); -/* - * Huawei Exxx radio devices have a built in flash disk which is their - * default power up configuration. This allows the device to carry its - * own installation software. - * - * Instead of following the USB spec, and create multiple configuration - * descriptors for this, the devices expects the driver to send - * UF_DEVICE_REMOTE_WAKEUP to endpoint 2 to reset the device, so it - * reprobes, now with the radio exposed. - */ - -static usbd_status -ubsa_huawei(device_t self, struct usb_attach_arg *uaa) { - usb_device_request_t req; usbd_device_handle dev; - usb_config_descriptor_t *cdesc; - - if (self == NULL) - return (UMATCH_NONE); - if (uaa == NULL) - return (UMATCH_NONE); - dev = uaa->device; - if (dev == NULL) - return (UMATCH_NONE); - /* get the config descriptor */ - cdesc = usbd_get_config_descriptor(dev); - if (cdesc == NULL) - return (UMATCH_NONE); - - if (cdesc->bNumInterface > 1) - return (0); - - /* Bend it like Beckham */ - device_printf(self, "Kicking Huawei device into radio mode\n"); - memset(&req, 0, sizeof req); - req.bmRequestType = UT_WRITE_DEVICE; - req.bRequest = UR_SET_FEATURE; - USETW(req.wValue, UF_DEVICE_REMOTE_WAKEUP); - USETW(req.wIndex, 2); - USETW(req.wLength, 0); - - /* We get error return, but it works */ - (void)usbd_do_request(dev, &req, 0); - return (UMATCH_NONE); -} - - static int ubsa_match(device_t self) { @@ -399,9 +340,6 @@ ubsa_match(device_t self) for (i = 0; ubsa_products[i].vendor != 0; i++) { if (ubsa_products[i].vendor == uaa->vendor && ubsa_products[i].product == uaa->product) { - if (uaa->vendor == USB_VENDOR_HUAWEI && - ubsa_huawei(self, uaa)) - break; return (UMATCH_VENDOR_PRODUCT); } } @@ -424,9 +362,6 @@ ubsa_attach(device_t self) dev = uaa->device; ucom = &sc->sc_ucom; - if (uaa->vendor == USB_VENDOR_HUAWEI) - sc->sc_huawei = 1; - /* * initialize rts, dtr variables to something * different from boolean 0, 1 @@ -575,8 +510,6 @@ ubsa_request(struct ubsa_softc *sc, u_in usbd_status err; /* The huawei Exxx devices support none of these tricks */ - if (sc->sc_huawei) - return (0); req.bmRequestType = UT_WRITE_VENDOR_DEVICE; req.bRequest = request; USETW(req.wValue, value); Modified: head/sys/dev/usb/usbdevs ============================================================================== --- head/sys/dev/usb/usbdevs Thu Oct 9 20:51:25 2008 (r183734) +++ head/sys/dev/usb/usbdevs Thu Oct 9 21:25:01 2008 (r183735) @@ -1434,7 +1434,7 @@ product HTC SMARTPHONE 0x0a51 SmartPhon /* HUAWEI products */ product HUAWEI MOBILE 0x1001 Huawei Mobile -product HUAWEI E270 0x1003 Huawei HSPA modem +product HUAWEI E220 0x1003 Huawei HSDPA modem /* HUAWEI 3com products */ product HUAWEI3COM WUB320G 0x0009 Aolynk WUB320g Modified: head/sys/i386/conf/GENERIC ============================================================================== --- head/sys/i386/conf/GENERIC Thu Oct 9 20:51:25 2008 (r183734) +++ head/sys/i386/conf/GENERIC Thu Oct 9 21:25:01 2008 (r183735) @@ -304,6 +304,7 @@ device urio # Diamond Rio 500 MP3 play device uscanner # Scanners # USB Serial devices device ucom # Generic com ttys +device u3g # USB-based 3G modems (Option, Huawei, Sierra) device uark # Technologies ARK3116 based serial adapters device ubsa # Belkin F5U103 and compatible serial adapters device uftdi # For FTDI usb serial adapters Modified: head/sys/modules/Makefile ============================================================================== --- head/sys/modules/Makefile Thu Oct 9 20:51:25 2008 (r183734) +++ head/sys/modules/Makefile Thu Oct 9 21:25:01 2008 (r183735) @@ -269,6 +269,7 @@ SUBDIR= ${_3dfx} \ twe \ tx \ txp \ + u3g \ uark \ uart \ ubsa \ Added: head/sys/modules/u3g/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/modules/u3g/Makefile Thu Oct 9 21:25:01 2008 (r183735) @@ -0,0 +1,8 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../dev/usb + +KMOD= u3g +SRCS= u3g.c ucomvar.h opt_usb.h device_if.h bus_if.h usbdevs.h + +.include From imp at FreeBSD.org Thu Oct 9 22:01:27 2008 From: imp at FreeBSD.org (Warner Losh) Date: Thu Oct 9 22:01:34 2008 Subject: svn commit: r183736 - head/share/mk Message-ID: <200810092201.m99M1RFV072633@svn.freebsd.org> Author: imp Date: Thu Oct 9 22:01:27 2008 New Revision: 183736 URL: http://svn.freebsd.org/changeset/base/183736 Log: ata module additions now nest ata modules one deeper than any prior module. Increase heuristic used to find them by one. Modified: head/share/mk/bsd.kmod.mk Modified: head/share/mk/bsd.kmod.mk ============================================================================== --- head/share/mk/bsd.kmod.mk Thu Oct 9 21:25:01 2008 (r183735) +++ head/share/mk/bsd.kmod.mk Thu Oct 9 22:01:27 2008 (r183736) @@ -2,7 +2,7 @@ # Search for kernel source tree in standard places. .for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. ${.CURDIR}/../../../.. \ - /sys /usr/src/sys + ${.CURDIR}/../../../../.. /sys /usr/src/sys .if !defined(SYSDIR) && exists(${_dir}/kern/) && exists(${_dir}/conf/kmod.mk) SYSDIR= ${_dir} .endif From kan at FreeBSD.org Fri Oct 10 00:16:33 2008 From: kan at FreeBSD.org (Alexander Kabaev) Date: Fri Oct 10 00:16:39 2008 Subject: svn commit: r183737 - head/libexec/rtld-elf Message-ID: <200810100016.m9A0GWoo074921@svn.freebsd.org> Author: kan Date: Fri Oct 10 00:16:32 2008 New Revision: 183737 URL: http://svn.freebsd.org/changeset/base/183737 Log: Allow strong symbols to override weak ones for lookups done through dlsym with RTLD_NEXT/RTLD_SELF handles. Allow symbols from ld-elf.so to be located this way too. Based on report and original patch from sobomax@. Modified: head/libexec/rtld-elf/rtld.c Modified: head/libexec/rtld-elf/rtld.c ============================================================================== --- head/libexec/rtld-elf/rtld.c Thu Oct 9 22:01:27 2008 (r183736) +++ head/libexec/rtld-elf/rtld.c Fri Oct 10 00:16:32 2008 (r183737) @@ -1925,7 +1925,7 @@ do_dlsym(void *handle, const char *name, { DoneList donelist; const Obj_Entry *obj, *defobj; - const Elf_Sym *def; + const Elf_Sym *def, *symp; unsigned long hash; int lockstate; @@ -1951,9 +1951,26 @@ do_dlsym(void *handle, const char *name, if (handle == RTLD_NEXT) obj = obj->next; for (; obj != NULL; obj = obj->next) { - if ((def = symlook_obj(name, hash, obj, ve, flags)) != NULL) { - defobj = obj; - break; + if ((symp = symlook_obj(name, hash, obj, ve, flags)) != NULL) { + if (def == NULL || ELF_ST_BIND(symp->st_info) != STB_WEAK) { + def = symp; + defobj = obj; + if (ELF_ST_BIND(def->st_info) != STB_WEAK) + break; + } + } + } + /* + * Search the dynamic linker itself, and possibly resolve the + * symbol from there. This is how the application links to + * dynamic linker services such as dlopen. Only the values listed + * in the "exports" array can be resolved from the dynamic linker. + */ + if (def == NULL || ELF_ST_BIND(def->st_info) == STB_WEAK) { + symp = symlook_obj(name, hash, &obj_rtld, ve, flags); + if (symp != NULL && is_exported(symp)) { + def = symp; + defobj = &obj_rtld; } } } else { From jkoshy at FreeBSD.org Fri Oct 10 04:23:41 2008 From: jkoshy at FreeBSD.org (Joseph Koshy) Date: Fri Oct 10 04:23:48 2008 Subject: svn commit: r183738 - head Message-ID: <200810100423.m9A4NfED082645@svn.freebsd.org> Author: jkoshy Date: Fri Oct 10 04:23:40 2008 New Revision: 183738 URL: http://svn.freebsd.org/changeset/base/183738 Log: Mention the libpmc/hwpmc ABI change introduced in SVN r183725. Modified: head/UPDATING Modified: head/UPDATING ============================================================================== --- head/UPDATING Fri Oct 10 00:16:32 2008 (r183737) +++ head/UPDATING Fri Oct 10 04:23:40 2008 (r183738) @@ -22,6 +22,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8. to maximize performance. (To disable malloc debugging, run ln -s aj /etc/malloc.conf.) +20081009: + The ABI used by the PMC toolset has changed. Please keep + userland (libpmc(3)) and the kernel module (hwpmc(4)) in + sync. + 20080820: The TTY subsystem of the kernel has been replaced by a new implementation, which provides better scalability and an From imp at FreeBSD.org Fri Oct 10 05:10:11 2008 From: imp at FreeBSD.org (Warner Losh) Date: Fri Oct 10 05:10:17 2008 Subject: svn commit: r183739 - head/libexec/rtld-elf/mips Message-ID: <200810100510.m9A5AAnM083465@svn.freebsd.org> Author: imp Date: Fri Oct 10 05:10:10 2008 New Revision: 183739 URL: http://svn.freebsd.org/changeset/base/183739 Log: MFp4: Fix a bug in the mips relocation code that prevents shared images from working. From p4 filelog of the upstream file in p4 //depot/projects/mips2-jnpr/src/libexec/rtld-elf/mips/reloc.c ... #6 change 140737 edit on 2008/04/27 by gonzo@gonzo_jeeves (text+ko) o Looks like handler for R_MIPS_REL32 brought by CS 137942 is broken for tradmips. Code from NetBSD's libexec/ld.elf_so/arch/mips/mips_reloc.c works just fine. ... #3 change 137942 edit on 2008/03/17 by rrs@rrs-mips2-jnpr (text+ko) Any relocation symbol lookup if its 0. It looks like this is the way the compiler indicates you need to look in another shared library. When we hit these as we relocate a object we will do the symbol lookups and setup the relocation table with the right value. Submitted by: rrs@, gonzo@ Modified: head/libexec/rtld-elf/mips/reloc.c Modified: head/libexec/rtld-elf/mips/reloc.c ============================================================================== --- head/libexec/rtld-elf/mips/reloc.c Fri Oct 10 04:23:40 2008 (r183738) +++ head/libexec/rtld-elf/mips/reloc.c Fri Oct 10 05:10:10 2008 (r183739) @@ -258,31 +258,23 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry case R_TYPE(REL32): /* 32-bit PC-relative reference */ def = obj->symtab + symnum; - tmp = load_ptr(where); - if (tmp == 0) { - def = find_symdef(symnum, obj, &defobj, false, NULL); - if (def == NULL) { - dbg("Warning5, cant find symbole %d:%s", (int)symnum, - obj->strtab + obj->symtab[symnum].st_name); - } else { - tmp = def->st_value + (Elf_Addr)defobj->relocbase; - dbg("Correctiong symnum:%d:%s to addr:%x", (int)symnum, - obj->strtab + obj->symtab[symnum].st_name, - (u_int32_t)tmp - ); - } + if (symnum >= obj->gotsym) { + tmp = load_ptr(where); + tmp += got[obj->local_gotno + symnum - obj->gotsym]; + store_ptr(where, tmp); + break; } else { - tmp += (Elf_Addr)obj->relocbase; - } - store_ptr(where, tmp); - if (tmp == (Elf_Addr)obj->relocbase) { - dbg("rel sym %p falls on relocbase symidx:%x symbol:%s", rel, - (uint32_t)ELF_R_SYM(rel->r_info), - obj->strtab + obj->symtab[symnum].st_name - ); + tmp = load_ptr(where); + + if (def->st_info == + ELF_ST_INFO(STB_LOCAL, STT_SECTION) + ) + tmp += (Elf_Addr)def->st_value; + + tmp += (Elf_Addr)obj->relocbase; + store_ptr(where, tmp); } break; - default: dbg("sym = %lu, type = %lu, offset = %p, " "contents = %p, symbol = %s", From n_hibma at FreeBSD.org Fri Oct 10 06:26:37 2008 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Fri Oct 10 06:26:49 2008 Subject: svn commit: r183740 - head/share/man/man4 Message-ID: <200810100626.m9A6QbZP084776@svn.freebsd.org> Author: n_hibma Date: Fri Oct 10 06:26:37 2008 New Revision: 183740 URL: http://svn.freebsd.org/changeset/base/183740 Log: Wrong FBSD version number in HISTORY section. Submitted by: pluknet Modified: head/share/man/man4/u3g.4 Modified: head/share/man/man4/u3g.4 ============================================================================== --- head/share/man/man4/u3g.4 Fri Oct 10 05:10:10 2008 (r183739) +++ head/share/man/man4/u3g.4 Fri Oct 10 06:26:37 2008 (r183740) @@ -84,7 +84,7 @@ The .Nm driver appeared in -.Fx 7.0 . +.Fx 8.0 . The .Xr ubsa 4 manual page was modified for From n_hibma at FreeBSD.org Fri Oct 10 06:37:52 2008 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Fri Oct 10 06:38:04 2008 Subject: svn commit: r183741 - head Message-ID: <200810100637.m9A6bqoI085013@svn.freebsd.org> Author: n_hibma Date: Fri Oct 10 06:37:51 2008 New Revision: 183741 URL: http://svn.freebsd.org/changeset/base/183741 Log: Add an entry about the split up of usb into usb+*hci modules. Submitted by: Andrew Thompson Modified: head/UPDATING Modified: head/UPDATING ============================================================================== --- head/UPDATING Fri Oct 10 06:26:37 2008 (r183740) +++ head/UPDATING Fri Oct 10 06:37:51 2008 (r183741) @@ -23,6 +23,16 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8. ln -s aj /etc/malloc.conf.) 20081009: + The uhci, ohci, ehci and slhci USB Host controller drivers have + been put into separate modules. If you load the usb module + separately through loader.conf you will need to load the + appropriate *hci module as well. E.g. for a UHCI-based USB 2.0 + controller add the following to loader.conf: + + uhci_load="YES" + ehci_load="YES" + +20081009: The ABI used by the PMC toolset has changed. Please keep userland (libpmc(3)) and the kernel module (hwpmc(4)) in sync. From n_hibma at FreeBSD.org Fri Oct 10 07:16:45 2008 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Fri Oct 10 07:16:51 2008 Subject: svn commit: r183742 - head/sys/dev/usb Message-ID: <200810100716.m9A7GiTs085669@svn.freebsd.org> Author: n_hibma Date: Fri Oct 10 07:16:44 2008 New Revision: 183742 URL: http://svn.freebsd.org/changeset/base/183742 Log: Typo in ifdef. Submitted by: Andrew Thompson Modified: head/sys/dev/usb/u3g.c Modified: head/sys/dev/usb/u3g.c ============================================================================== --- head/sys/dev/usb/u3g.c Fri Oct 10 06:37:51 2008 (r183741) +++ head/sys/dev/usb/u3g.c Fri Oct 10 07:16:44 2008 (r183742) @@ -165,7 +165,7 @@ u3g_attach(device_t self) char devnamefmt[32]; sc->sc_dev = self; -#ifdef DEBUG +#ifdef U3G_DEBUG sc->sc_intr_number = -1; sc->sc_intr_pipe = NULL; #endif From rwatson at FreeBSD.org Fri Oct 10 14:33:48 2008 From: rwatson at FreeBSD.org (Robert Watson) Date: Fri Oct 10 14:33:54 2008 Subject: svn commit: r183744 - head/sys/netinet Message-ID: <200810101433.m9AEXlH5093736@svn.freebsd.org> Author: rwatson Date: Fri Oct 10 14:33:47 2008 New Revision: 183744 URL: http://svn.freebsd.org/changeset/base/183744 Log: Fix content and spelling of comment on _ipfw_insn.len -- a count of 32-bit words, not 32-byte words. MFC after: 3 days Modified: head/sys/netinet/ip_fw.h Modified: head/sys/netinet/ip_fw.h ============================================================================== --- head/sys/netinet/ip_fw.h Fri Oct 10 11:39:59 2008 (r183743) +++ head/sys/netinet/ip_fw.h Fri Oct 10 14:33:47 2008 (r183744) @@ -223,7 +223,7 @@ enum ipfw_opcodes { /* arguments (4 byt */ typedef struct _ipfw_insn { /* template for instructions */ enum ipfw_opcodes opcode:8; - u_int8_t len; /* numer of 32-byte words */ + u_int8_t len; /* number of 32-bit words */ #define F_NOT 0x80 #define F_OR 0x40 #define F_LEN_MASK 0x3f From imp at FreeBSD.org Fri Oct 10 17:49:47 2008 From: imp at FreeBSD.org (Warner Losh) Date: Fri Oct 10 17:50:01 2008 Subject: svn commit: r183750 - head/sys/kern Message-ID: <200810101749.m9AHnlCh097237@svn.freebsd.org> Author: imp Date: Fri Oct 10 17:49:47 2008 New Revision: 183750 URL: http://svn.freebsd.org/changeset/base/183750 Log: Close, but not eliminate, a race condition. It is one that properly designed drivers would never hit, but was exposed in diving into another problem... When expanding the devclass array, free the old memory after updating the pointer to the new memory. For the following single race case, this helps: allocate new memory copy to new memory free old memory read pointer to freed memory update pointer to new memory Now we do allocate new memory copy to new memory update pointer to new memory free old memory Which closes this problem, but doesn't even begin to address the multicpu races, which all should be covered by Giant at the moment, but likely aren't completely. Note: reviewers were ok with this fix, but suggested the use case wasn't one we wanted to encourage. Reviewed by: jhb, scottl. Modified: head/sys/kern/subr_bus.c Modified: head/sys/kern/subr_bus.c ============================================================================== --- head/sys/kern/subr_bus.c Fri Oct 10 17:48:39 2008 (r183749) +++ head/sys/kern/subr_bus.c Fri Oct 10 17:49:47 2008 (r183750) @@ -1344,20 +1344,22 @@ devclass_alloc_unit(devclass_t dc, int * * this one. */ if (unit >= dc->maxunit) { - device_t *newlist; + device_t *newlist, *oldlist; int newsize; + oldlist = dc->devices; newsize = roundup((unit + 1), MINALLOCSIZE / sizeof(device_t)); newlist = malloc(sizeof(device_t) * newsize, M_BUS, M_NOWAIT); if (!newlist) return (ENOMEM); - bcopy(dc->devices, newlist, sizeof(device_t) * dc->maxunit); + if (oldlist != NULL) + bcopy(oldlist, newlist, sizeof(device_t) * dc->maxunit); bzero(newlist + dc->maxunit, sizeof(device_t) * (newsize - dc->maxunit)); - if (dc->devices) - free(dc->devices, M_BUS); dc->devices = newlist; dc->maxunit = newsize; + if (oldlist != NULL) + free(oldlist, M_BUS); } PDEBUG(("now: unit %d in devclass %s", unit, DEVCLANAME(dc))); From n_hibma at FreeBSD.org Fri Oct 10 20:05:16 2008 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Fri Oct 10 20:05:22 2008 Subject: svn commit: r183752 - head/sys/dev/usb Message-ID: <200810102005.m9AK5Gno099618@svn.freebsd.org> Author: n_hibma Date: Fri Oct 10 20:05:15 2008 New Revision: 183752 URL: http://svn.freebsd.org/changeset/base/183752 Log: Typo. Modified: head/sys/dev/usb/umct.c Modified: head/sys/dev/usb/umct.c ============================================================================== --- head/sys/dev/usb/umct.c Fri Oct 10 17:53:26 2008 (r183751) +++ head/sys/dev/usb/umct.c Fri Oct 10 20:05:15 2008 (r183752) @@ -314,7 +314,7 @@ umct_request(struct umct_softc *sc, uint err = usbd_do_request(sc->sc_ucom.sc_udev, &req, oval); if (err) - printf("%s: ubsa_request: %s\n", + printf("%s: umct_request: %s\n", device_get_nameunit(sc->sc_ucom.sc_dev), usbd_errstr(err)); return (err); } From attilio at FreeBSD.org Fri Oct 10 21:23:52 2008 From: attilio at FreeBSD.org (Attilio Rao) Date: Fri Oct 10 21:23:59 2008 Subject: svn commit: r183754 - in head/sys: cddl/contrib/opensolaris/uts/common/fs/zfs fs/cd9660 fs/hpfs fs/msdosfs fs/ntfs fs/nwfs fs/smbfs fs/udf geom gnu/fs/ext2fs gnu/fs/xfs/FreeBSD kern nfsclient sys u... Message-ID: <200810102123.m9ALNpou001340@svn.freebsd.org> Author: attilio Date: Fri Oct 10 21:23:50 2008 New Revision: 183754 URL: http://svn.freebsd.org/changeset/base/183754 Log: Remove the struct thread unuseful argument from bufobj interface. In particular following functions KPI results modified: - bufobj_invalbuf() - bufsync() and BO_SYNC() "virtual method" of the buffer objects set. Main consumers of bufobj functions are affected by this change too and, in particular, functions which changed their KPI are: - vinvalbuf() - g_vfs_close() Due to the KPI breakage, __FreeBSD_version will be bumped in a later commit. As a side note, please consider just temporary the 'curthread' argument passing to VOP_SYNC() (in bufsync()) as it will be axed out ASAP Reviewed by: kib Tested by: Giovanni Trematerra Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c head/sys/fs/cd9660/cd9660_vfsops.c head/sys/fs/hpfs/hpfs_vfsops.c head/sys/fs/msdosfs/msdosfs_vfsops.c head/sys/fs/ntfs/ntfs_vfsops.c head/sys/fs/nwfs/nwfs_io.c head/sys/fs/smbfs/smbfs_io.c head/sys/fs/udf/udf_vfsops.c head/sys/geom/geom_vfs.c head/sys/geom/geom_vfs.h head/sys/gnu/fs/ext2fs/ext2_vfsops.c head/sys/gnu/fs/xfs/FreeBSD/xfs_buf.c head/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c head/sys/gnu/fs/xfs/FreeBSD/xfs_super.c head/sys/kern/vfs_bio.c head/sys/kern/vfs_mount.c head/sys/kern/vfs_subr.c head/sys/nfsclient/nfs_bio.c head/sys/sys/bufobj.h head/sys/sys/vnode.h head/sys/ufs/ffs/ffs_inode.c head/sys/ufs/ffs/ffs_vfsops.c head/sys/vm/vm_object.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c Fri Oct 10 21:23:50 2008 (r183754) @@ -916,7 +916,7 @@ zfs_freesp(znode_t *zp, uint64_t off, ui #if 0 error = vtruncbuf(vp, curthread->td_ucred, curthread, end, PAGE_SIZE); #else - error = vinvalbuf(vp, V_SAVE, curthread, 0, 0); + error = vinvalbuf(vp, V_SAVE, 0, 0); vnode_pager_setsize(vp, end); #endif } Modified: head/sys/fs/cd9660/cd9660_vfsops.c ============================================================================== --- head/sys/fs/cd9660/cd9660_vfsops.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/fs/cd9660/cd9660_vfsops.c Fri Oct 10 21:23:50 2008 (r183754) @@ -88,8 +88,7 @@ static struct vfsops cd9660_vfsops = { VFS_SET(cd9660_vfsops, cd9660, VFCF_READONLY); MODULE_VERSION(cd9660, 1); -static int iso_mountfs(struct vnode *devvp, struct mount *mp, - struct thread *td); +static int iso_mountfs(struct vnode *devvp, struct mount *mp); /* * VFS Operations. @@ -181,7 +180,7 @@ cd9660_mount(struct mount *mp, struct th VOP_UNLOCK(devvp, 0); if ((mp->mnt_flag & MNT_UPDATE) == 0) { - error = iso_mountfs(devvp, mp, td); + error = iso_mountfs(devvp, mp); } else { if (devvp != imp->im_devvp) error = EINVAL; /* needs translation */ @@ -200,10 +199,9 @@ cd9660_mount(struct mount *mp, struct th * Common code for mount and mountroot */ static int -iso_mountfs(devvp, mp, td) +iso_mountfs(devvp, mp) struct vnode *devvp; struct mount *mp; - struct thread *td; { struct iso_mnt *isomp = (struct iso_mnt *)0; struct buf *bp = NULL; @@ -249,7 +247,7 @@ iso_mountfs(devvp, mp, td) if ((ISO_DEFAULT_BLOCK_SIZE % cp->provider->sectorsize) != 0) { DROP_GIANT(); g_topology_lock(); - g_vfs_close(cp, td); + g_vfs_close(cp); g_topology_unlock(); PICKUP_GIANT(); return (EINVAL); @@ -482,7 +480,7 @@ out: if (cp != NULL) { DROP_GIANT(); g_topology_lock(); - g_vfs_close(cp, td); + g_vfs_close(cp); g_topology_unlock(); PICKUP_GIANT(); } @@ -525,7 +523,7 @@ cd9660_unmount(mp, mntflags, td) } DROP_GIANT(); g_topology_lock(); - g_vfs_close(isomp->im_cp, td); + g_vfs_close(isomp->im_cp); g_topology_unlock(); PICKUP_GIANT(); vrele(isomp->im_devvp); Modified: head/sys/fs/hpfs/hpfs_vfsops.c ============================================================================== --- head/sys/fs/hpfs/hpfs_vfsops.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/fs/hpfs/hpfs_vfsops.c Fri Oct 10 21:23:50 2008 (r183754) @@ -325,7 +325,7 @@ failed: mp->mnt_data = NULL; DROP_GIANT(); g_topology_lock(); - g_vfs_close(cp, td); + g_vfs_close(cp); g_topology_unlock(); PICKUP_GIANT(); return (error); @@ -356,10 +356,10 @@ hpfs_unmount( return (error); } - vinvalbuf(hpmp->hpm_devvp, V_SAVE, td, 0, 0); + vinvalbuf(hpmp->hpm_devvp, V_SAVE, 0, 0); DROP_GIANT(); g_topology_lock(); - g_vfs_close(hpmp->hpm_cp, td); + g_vfs_close(hpmp->hpm_cp); g_topology_unlock(); PICKUP_GIANT(); vrele(hpmp->hpm_devvp); Modified: head/sys/fs/msdosfs/msdosfs_vfsops.c ============================================================================== --- head/sys/fs/msdosfs/msdosfs_vfsops.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/fs/msdosfs/msdosfs_vfsops.c Fri Oct 10 21:23:50 2008 (r183754) @@ -103,8 +103,7 @@ static MALLOC_DEFINE(M_MSDOSFSFAT, "msdo struct iconv_functions *msdosfs_iconv; static int update_mp(struct mount *mp, struct thread *td); -static int mountmsdosfs(struct vnode *devvp, struct mount *mp, - struct thread *td); +static int mountmsdosfs(struct vnode *devvp, struct mount *mp); static vfs_fhtovp_t msdosfs_fhtovp; static vfs_mount_t msdosfs_mount; static vfs_root_t msdosfs_root; @@ -375,7 +374,7 @@ msdosfs_mount(struct mount *mp, struct t return (error); } if ((mp->mnt_flag & MNT_UPDATE) == 0) { - error = mountmsdosfs(devvp, mp, td); + error = mountmsdosfs(devvp, mp); #ifdef MSDOSFS_DEBUG /* only needed for the printf below */ pmp = VFSTOMSDOSFS(mp); #endif @@ -405,7 +404,7 @@ msdosfs_mount(struct mount *mp, struct t } static int -mountmsdosfs(struct vnode *devvp, struct mount *mp, struct thread *td) +mountmsdosfs(struct vnode *devvp, struct mount *mp) { struct msdosfsmount *pmp; struct buf *bp; @@ -754,7 +753,7 @@ error_exit: if (cp != NULL) { DROP_GIANT(); g_topology_lock(); - g_vfs_close(cp, td); + g_vfs_close(cp); g_topology_unlock(); PICKUP_GIANT(); } @@ -824,7 +823,7 @@ msdosfs_unmount(struct mount *mp, int mn #endif DROP_GIANT(); g_topology_lock(); - g_vfs_close(pmp->pm_cp, td); + g_vfs_close(pmp->pm_cp); g_topology_unlock(); PICKUP_GIANT(); vrele(pmp->pm_devvp); Modified: head/sys/fs/ntfs/ntfs_vfsops.c ============================================================================== --- head/sys/fs/ntfs/ntfs_vfsops.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/fs/ntfs/ntfs_vfsops.c Fri Oct 10 21:23:50 2008 (r183754) @@ -462,7 +462,7 @@ out: DROP_GIANT(); g_topology_lock(); - g_vfs_close(cp, td); + g_vfs_close(cp); g_topology_unlock(); PICKUP_GIANT(); @@ -506,11 +506,11 @@ ntfs_unmount( if (error) printf("ntfs_unmount: vflush failed(sysnodes): %d\n",error); - vinvalbuf(ntmp->ntm_devvp, V_SAVE, td, 0, 0); + vinvalbuf(ntmp->ntm_devvp, V_SAVE, 0, 0); DROP_GIANT(); g_topology_lock(); - g_vfs_close(ntmp->ntm_cp, td); + g_vfs_close(ntmp->ntm_cp); g_topology_unlock(); PICKUP_GIANT(); Modified: head/sys/fs/nwfs/nwfs_io.c ============================================================================== --- head/sys/fs/nwfs/nwfs_io.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/fs/nwfs/nwfs_io.c Fri Oct 10 21:23:50 2008 (r183754) @@ -618,7 +618,7 @@ nwfs_vinvalbuf(vp, td) VM_OBJECT_UNLOCK(vp->v_bufobj.bo_object); } - error = vinvalbuf(vp, V_SAVE, td, PCATCH, 0); + error = vinvalbuf(vp, V_SAVE, PCATCH, 0); while (error) { if (error == ERESTART || error == EINTR) { np->n_flag &= ~NFLUSHINPROG; @@ -628,7 +628,7 @@ nwfs_vinvalbuf(vp, td) } return EINTR; } - error = vinvalbuf(vp, V_SAVE, td, PCATCH, 0); + error = vinvalbuf(vp, V_SAVE, PCATCH, 0); } np->n_flag &= ~(NMODIFIED | NFLUSHINPROG); if (np->n_flag & NFLUSHWANT) { Modified: head/sys/fs/smbfs/smbfs_io.c ============================================================================== --- head/sys/fs/smbfs/smbfs_io.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/fs/smbfs/smbfs_io.c Fri Oct 10 21:23:50 2008 (r183754) @@ -690,7 +690,7 @@ smbfs_vinvalbuf(struct vnode *vp, struct VM_OBJECT_UNLOCK(vp->v_bufobj.bo_object); } - error = vinvalbuf(vp, V_SAVE, td, PCATCH, 0); + error = vinvalbuf(vp, V_SAVE, PCATCH, 0); while (error) { if (error == ERESTART || error == EINTR) { np->n_flag &= ~NFLUSHINPROG; @@ -700,7 +700,7 @@ smbfs_vinvalbuf(struct vnode *vp, struct } return EINTR; } - error = vinvalbuf(vp, V_SAVE, td, PCATCH, 0); + error = vinvalbuf(vp, V_SAVE, PCATCH, 0); } np->n_flag &= ~(NMODIFIED | NFLUSHINPROG); if (np->n_flag & NFLUSHWANT) { Modified: head/sys/fs/udf/udf_vfsops.c ============================================================================== --- head/sys/fs/udf/udf_vfsops.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/fs/udf/udf_vfsops.c Fri Oct 10 21:23:50 2008 (r183754) @@ -134,7 +134,7 @@ VFS_SET(udf_vfsops, udf, VFCF_READONLY); MODULE_VERSION(udf, 1); -static int udf_mountfs(struct vnode *, struct mount *, struct thread *); +static int udf_mountfs(struct vnode *, struct mount *); static int udf_init(struct vfsconf *foo) @@ -243,7 +243,7 @@ udf_mount(struct mount *mp, struct threa return (error); } - if ((error = udf_mountfs(devvp, mp, td))) { + if ((error = udf_mountfs(devvp, mp))) { vrele(devvp); return (error); } @@ -301,7 +301,7 @@ udf_checktag(struct desc_tag *tag, uint1 } static int -udf_mountfs(struct vnode *devvp, struct mount *mp, struct thread *td) { +udf_mountfs(struct vnode *devvp, struct mount *mp) { struct buf *bp = NULL; struct anchor_vdp avdp; struct udf_mnt *udfmp = NULL; @@ -365,7 +365,7 @@ udf_mountfs(struct vnode *devvp, struct (logical_secsize < cp->provider->sectorsize)) { DROP_GIANT(); g_topology_lock(); - g_vfs_close(cp, td); + g_vfs_close(cp); g_topology_unlock(); PICKUP_GIANT(); return (EINVAL); @@ -493,7 +493,7 @@ bail: brelse(bp); DROP_GIANT(); g_topology_lock(); - g_vfs_close(cp, td); + g_vfs_close(cp); g_topology_unlock(); PICKUP_GIANT(); return error; @@ -524,7 +524,7 @@ udf_unmount(struct mount *mp, int mntfla DROP_GIANT(); g_topology_lock(); - g_vfs_close(udfmp->im_cp, td); + g_vfs_close(udfmp->im_cp); g_topology_unlock(); PICKUP_GIANT(); vrele(udfmp->im_devvp); Modified: head/sys/geom/geom_vfs.c ============================================================================== --- head/sys/geom/geom_vfs.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/geom/geom_vfs.c Fri Oct 10 21:23:50 2008 (r183754) @@ -163,7 +163,7 @@ g_vfs_open(struct vnode *vp, struct g_co } void -g_vfs_close(struct g_consumer *cp, struct thread *td) +g_vfs_close(struct g_consumer *cp) { struct g_geom *gp; struct bufobj *bo; @@ -172,6 +172,6 @@ g_vfs_close(struct g_consumer *cp, struc gp = cp->geom; bo = gp->softc; - bufobj_invalbuf(bo, V_SAVE, td, 0, 0); + bufobj_invalbuf(bo, V_SAVE, 0, 0); g_wither_geom_close(gp, ENXIO); } Modified: head/sys/geom/geom_vfs.h ============================================================================== --- head/sys/geom/geom_vfs.h Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/geom/geom_vfs.h Fri Oct 10 21:23:50 2008 (r183754) @@ -37,6 +37,6 @@ extern struct buf_ops *g_vfs_bufops; void g_vfs_strategy(struct bufobj *bo, struct buf *bp); int g_vfs_open(struct vnode *vp, struct g_consumer **cpp, const char *fsname, int wr); -void g_vfs_close(struct g_consumer *cp, struct thread *td); +void g_vfs_close(struct g_consumer *cp); #endif /* _GEOM_GEOM_VFS_H_ */ Modified: head/sys/gnu/fs/ext2fs/ext2_vfsops.c ============================================================================== --- head/sys/gnu/fs/ext2fs/ext2_vfsops.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/gnu/fs/ext2fs/ext2_vfsops.c Fri Oct 10 21:23:50 2008 (r183754) @@ -82,7 +82,7 @@ #include static int ext2_flushfiles(struct mount *mp, int flags, struct thread *td); -static int ext2_mountfs(struct vnode *, struct mount *, struct thread *); +static int ext2_mountfs(struct vnode *, struct mount *); static int ext2_reload(struct mount *mp, struct thread *td); static int ext2_sbupdate(struct ext2mount *, int); @@ -277,7 +277,7 @@ ext2_mount(mp, td) } if ((mp->mnt_flag & MNT_UPDATE) == 0) { - error = ext2_mountfs(devvp, mp, td); + error = ext2_mountfs(devvp, mp); } else { if (devvp != ump->um_devvp) { vput(devvp); @@ -518,7 +518,7 @@ ext2_reload(struct mount *mp, struct thr */ devvp = VFSTOEXT2(mp)->um_devvp; vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); - if (vinvalbuf(devvp, 0, td, 0, 0) != 0) + if (vinvalbuf(devvp, 0, 0, 0) != 0) panic("ext2_reload: dirty1"); VOP_UNLOCK(devvp, 0); @@ -562,7 +562,7 @@ loop: MNT_VNODE_FOREACH_ABORT(mp, mvp); goto loop; } - if (vinvalbuf(vp, 0, td, 0, 0)) + if (vinvalbuf(vp, 0, 0, 0)) panic("ext2_reload: dirty2"); /* * Step 5: re-read inode data for all active vnodes. @@ -592,10 +592,9 @@ loop: * Common code for mount and mountroot */ static int -ext2_mountfs(devvp, mp, td) +ext2_mountfs(devvp, mp) struct vnode *devvp; struct mount *mp; - struct thread *td; { struct ext2mount *ump; struct buf *bp; @@ -623,7 +622,7 @@ ext2_mountfs(devvp, mp, td) (SBSIZE < cp->provider->sectorsize)) { DROP_GIANT(); g_topology_lock(); - g_vfs_close(cp, td); + g_vfs_close(cp); g_topology_unlock(); PICKUP_GIANT(); return (EINVAL); @@ -714,7 +713,7 @@ out: if (cp != NULL) { DROP_GIANT(); g_topology_lock(); - g_vfs_close(cp, td); + g_vfs_close(cp); g_topology_unlock(); PICKUP_GIANT(); } @@ -773,7 +772,7 @@ ext2_unmount(mp, mntflags, td) DROP_GIANT(); g_topology_lock(); - g_vfs_close(ump->um_cp, td); + g_vfs_close(ump->um_cp); g_topology_unlock(); PICKUP_GIANT(); vrele(ump->um_devvp); Modified: head/sys/gnu/fs/xfs/FreeBSD/xfs_buf.c ============================================================================== --- head/sys/gnu/fs/xfs/FreeBSD/xfs_buf.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/gnu/fs/xfs/FreeBSD/xfs_buf.c Fri Oct 10 21:23:50 2008 (r183754) @@ -266,7 +266,7 @@ xfs_flush_buftarg( { int error = 0; - error = vinvalbuf(btp->specvp, V_SAVE|V_NORMAL, curthread, 0, 0); + error = vinvalbuf(btp->specvp, V_SAVE | V_NORMAL, 0, 0); return error; } Modified: head/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c ============================================================================== --- head/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c Fri Oct 10 21:23:50 2008 (r183754) @@ -246,7 +246,7 @@ _xfs_mount(struct mount *mp, if (cp != NULL) { DROP_GIANT(); g_topology_lock(); - g_vfs_close(cp, td); + g_vfs_close(cp); g_topology_unlock(); PICKUP_GIANT(); } @@ -283,7 +283,7 @@ _xfs_unmount(mp, mntflags, td) if (cp != NULL) { DROP_GIANT(); g_topology_lock(); - g_vfs_close(cp, td); + g_vfs_close(cp); g_topology_unlock(); PICKUP_GIANT(); } @@ -483,9 +483,10 @@ xfs_geom_bufwrite(struct buf *bp) } static int -xfs_geom_bufsync(struct bufobj *bo, int waitfor, struct thread *td) +xfs_geom_bufsync(struct bufobj *bo, int waitfor) { - return bufsync(bo,waitfor,td); + + return (bufsync(bo, waitfor)); } static void Modified: head/sys/gnu/fs/xfs/FreeBSD/xfs_super.c ============================================================================== --- head/sys/gnu/fs/xfs/FreeBSD/xfs_super.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/gnu/fs/xfs/FreeBSD/xfs_super.c Fri Oct 10 21:23:50 2008 (r183754) @@ -207,7 +207,7 @@ xfs_blkdev_put( if (devvp == NULL) return; - vinvalbuf(devvp, V_SAVE, curthread, 0, 0); + vinvalbuf(devvp, V_SAVE, 0, 0); cp = devvp->v_bufobj.bo_private; DROP_GIANT(); Modified: head/sys/kern/vfs_bio.c ============================================================================== --- head/sys/kern/vfs_bio.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/kern/vfs_bio.c Fri Oct 10 21:23:50 2008 (r183754) @@ -3778,10 +3778,10 @@ bwait(struct buf *bp, u_char pri, const } int -bufsync(struct bufobj *bo, int waitfor, struct thread *td) +bufsync(struct bufobj *bo, int waitfor) { - return (VOP_FSYNC(bo->__bo_vnode, waitfor, td)); + return (VOP_FSYNC(bo->__bo_vnode, waitfor, curthread)); } void Modified: head/sys/kern/vfs_mount.c ============================================================================== --- head/sys/kern/vfs_mount.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/kern/vfs_mount.c Fri Oct 10 21:23:50 2008 (r183754) @@ -967,7 +967,7 @@ vfs_domount( return (error); } } - error = vinvalbuf(vp, V_SAVE, td, 0, 0); + error = vinvalbuf(vp, V_SAVE, 0, 0); if (error != 0) { vput(vp); return (error); @@ -1573,7 +1573,7 @@ devfs_fixup(struct thread *td) if (vp->v_type != VDIR) { vput(vp); } - error = vinvalbuf(vp, V_SAVE, td, 0, 0); + error = vinvalbuf(vp, V_SAVE, 0, 0); if (error) { vput(vp); } Modified: head/sys/kern/vfs_subr.c ============================================================================== --- head/sys/kern/vfs_subr.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/kern/vfs_subr.c Fri Oct 10 21:23:50 2008 (r183754) @@ -1065,8 +1065,7 @@ insmntque(struct vnode *vp, struct mount * Called with the underlying object locked. */ int -bufobj_invalbuf(struct bufobj *bo, int flags, struct thread *td, int slpflag, - int slptimeo) +bufobj_invalbuf(struct bufobj *bo, int flags, int slpflag, int slptimeo) { int error; @@ -1079,7 +1078,7 @@ bufobj_invalbuf(struct bufobj *bo, int f } if (bo->bo_dirty.bv_cnt > 0) { BO_UNLOCK(bo); - if ((error = BO_SYNC(bo, MNT_WAIT, td)) != 0) + if ((error = BO_SYNC(bo, MNT_WAIT)) != 0) return (error); /* * XXX We could save a lock/unlock if this was only @@ -1149,13 +1148,12 @@ bufobj_invalbuf(struct bufobj *bo, int f * Called with the underlying object locked. */ int -vinvalbuf(struct vnode *vp, int flags, struct thread *td, int slpflag, - int slptimeo) +vinvalbuf(struct vnode *vp, int flags, int slpflag, int slptimeo) { CTR2(KTR_VFS, "vinvalbuf vp %p flags %d", vp, flags); ASSERT_VOP_LOCKED(vp, "vinvalbuf"); - return (bufobj_invalbuf(&vp->v_bufobj, flags, td, slpflag, slptimeo)); + return (bufobj_invalbuf(&vp->v_bufobj, flags, slpflag, slptimeo)); } /* @@ -2505,8 +2503,8 @@ vgonel(struct vnode *vp) mp = NULL; if (!TAILQ_EMPTY(&vp->v_bufobj.bo_dirty.bv_hd)) (void) vn_start_secondary_write(vp, &mp, V_WAIT); - if (vinvalbuf(vp, V_SAVE, td, 0, 0) != 0) - vinvalbuf(vp, 0, td, 0, 0); + if (vinvalbuf(vp, V_SAVE, 0, 0) != 0) + vinvalbuf(vp, 0, 0, 0); /* * If purging an active vnode, it must be closed and Modified: head/sys/nfsclient/nfs_bio.c ============================================================================== --- head/sys/nfsclient/nfs_bio.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/nfsclient/nfs_bio.c Fri Oct 10 21:23:50 2008 (r183754) @@ -1323,11 +1323,11 @@ nfs_vinvalbuf(struct vnode *vp, int flag goto out; } - error = vinvalbuf(vp, flags, td, slpflag, 0); + error = vinvalbuf(vp, flags, slpflag, 0); while (error) { if (intrflg && (error = nfs_sigintr(nmp, NULL, td))) goto out; - error = vinvalbuf(vp, flags, td, 0, slptimeo); + error = vinvalbuf(vp, flags, 0, slptimeo); } mtx_lock(&np->n_mtx); if (np->n_directio_asyncwr == 0) Modified: head/sys/sys/bufobj.h ============================================================================== --- head/sys/sys/bufobj.h Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/sys/bufobj.h Fri Oct 10 21:23:50 2008 (r183754) @@ -57,7 +57,6 @@ struct bufobj; struct buf_ops; -struct thread; extern struct buf_ops buf_ops_bio; @@ -72,7 +71,7 @@ struct bufv { typedef void b_strategy_t(struct bufobj *, struct buf *); typedef int b_write_t(struct buf *); -typedef int b_sync_t(struct bufobj *, int waitfor, struct thread *td); +typedef int b_sync_t(struct bufobj *, int waitfor); typedef void b_bdflush_t(struct bufobj *, struct buf *); struct buf_ops { @@ -84,7 +83,7 @@ struct buf_ops { }; #define BO_STRATEGY(bo, bp) ((bo)->bo_ops->bop_strategy((bo), (bp))) -#define BO_SYNC(bo, w, td) ((bo)->bo_ops->bop_sync((bo), (w), (td))) +#define BO_SYNC(bo, w) ((bo)->bo_ops->bop_sync((bo), (w))) #define BO_WRITE(bo, bp) ((bo)->bo_ops->bop_write((bp))) #define BO_BDFLUSH(bo, bp) ((bo)->bo_ops->bop_bdflush((bo), (bp))) @@ -123,9 +122,9 @@ struct bufobj { void bufobj_wdrop(struct bufobj *bo); void bufobj_wref(struct bufobj *bo); void bufobj_wrefl(struct bufobj *bo); -int bufobj_invalbuf(struct bufobj *bo, int flags, struct thread *td, int slpflag, int slptimeo); +int bufobj_invalbuf(struct bufobj *bo, int flags, int slpflag, int slptimeo); int bufobj_wwait(struct bufobj *bo, int slpflag, int timeo); -int bufsync(struct bufobj *bo, int waitfor, struct thread *td); +int bufsync(struct bufobj *bo, int waitfor); void bufbdflush(struct bufobj *bo, struct buf *bp); #endif /* defined(_KERNEL) || defined(_KVM_VNODE) */ Modified: head/sys/sys/vnode.h ============================================================================== --- head/sys/sys/vnode.h Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/sys/vnode.h Fri Oct 10 21:23:50 2008 (r183754) @@ -598,8 +598,7 @@ int vget(struct vnode *vp, int lockflag, void vgone(struct vnode *vp); void vhold(struct vnode *); void vholdl(struct vnode *); -int vinvalbuf(struct vnode *vp, int save, - struct thread *td, int slpflag, int slptimeo); +int vinvalbuf(struct vnode *vp, int save, int slpflag, int slptimeo); int vtruncbuf(struct vnode *vp, struct ucred *cred, struct thread *td, off_t length, int blksize); void vn_printf(struct vnode *vp, const char *fmt, ...) __printflike(2,3); Modified: head/sys/ufs/ffs/ffs_inode.c ============================================================================== --- head/sys/ufs/ffs/ffs_inode.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/ufs/ffs/ffs_inode.c Fri Oct 10 21:23:50 2008 (r183754) @@ -204,7 +204,7 @@ ffs_truncate(vp, length, flags, cred, td #ifdef QUOTA (void) chkdq(ip, -extblocks, NOCRED, 0); #endif - vinvalbuf(vp, V_ALT, td, 0, 0); + vinvalbuf(vp, V_ALT, 0, 0); ip->i_din2->di_extsize = 0; for (i = 0; i < NXADDR; i++) { oldblks[i] = ip->i_din2->di_extb[i]; @@ -280,7 +280,7 @@ ffs_truncate(vp, length, flags, cred, td softdep_setup_freeblocks(ip, length, needextclean ? IO_EXT | IO_NORMAL : IO_NORMAL); ASSERT_VOP_LOCKED(vp, "ffs_truncate1"); - vinvalbuf(vp, needextclean ? 0 : V_NORMAL, td, 0, 0); + vinvalbuf(vp, needextclean ? 0 : V_NORMAL, 0, 0); vnode_pager_setsize(vp, 0); ip->i_flag |= IN_CHANGE | IN_UPDATE; return (ffs_update(vp, 0)); Modified: head/sys/ufs/ffs/ffs_vfsops.c ============================================================================== --- head/sys/ufs/ffs/ffs_vfsops.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/ufs/ffs/ffs_vfsops.c Fri Oct 10 21:23:50 2008 (r183754) @@ -483,7 +483,7 @@ ffs_reload(struct mount *mp, struct thre */ devvp = VFSTOUFS(mp)->um_devvp; vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY); - if (vinvalbuf(devvp, 0, td, 0, 0) != 0) + if (vinvalbuf(devvp, 0, 0, 0) != 0) panic("ffs_reload: dirty1"); VOP_UNLOCK(devvp, 0); @@ -570,7 +570,7 @@ loop: MNT_VNODE_FOREACH_ABORT(mp, mvp); goto loop; } - if (vinvalbuf(vp, 0, td, 0, 0)) + if (vinvalbuf(vp, 0, 0, 0)) panic("ffs_reload: dirty2"); /* * Step 5: re-read inode data for all active vnodes. @@ -907,7 +907,7 @@ out: if (cp != NULL) { DROP_GIANT(); g_topology_lock(); - g_vfs_close(cp, td); + g_vfs_close(cp); g_topology_unlock(); PICKUP_GIANT(); } @@ -1098,7 +1098,7 @@ ffs_unmount(mp, mntflags, td) } DROP_GIANT(); g_topology_lock(); - g_vfs_close(ump->um_cp, td); + g_vfs_close(ump->um_cp); g_topology_unlock(); PICKUP_GIANT(); vrele(ump->um_devvp); Modified: head/sys/vm/vm_object.c ============================================================================== --- head/sys/vm/vm_object.c Fri Oct 10 21:18:12 2008 (r183753) +++ head/sys/vm/vm_object.c Fri Oct 10 21:23:50 2008 (r183754) @@ -654,7 +654,7 @@ vm_object_terminate(vm_object_t object) vm_object_page_clean(object, 0, 0, OBJPC_SYNC); VM_OBJECT_UNLOCK(object); - vinvalbuf(vp, V_SAVE, NULL, 0, 0); + vinvalbuf(vp, V_SAVE, 0, 0); VM_OBJECT_LOCK(object); } From bushman at FreeBSD.org Fri Oct 10 22:40:06 2008 From: bushman at FreeBSD.org (Michael Bushkov) Date: Fri Oct 10 22:40:23 2008 Subject: svn commit: r183755 - head/usr.sbin/nscd Message-ID: <200810102240.m9AMe5b1002759@svn.freebsd.org> Author: bushman Date: Fri Oct 10 22:40:05 2008 New Revision: 183755 URL: http://svn.freebsd.org/changeset/base/183755 Log: Removing startup banner. Modified: head/usr.sbin/nscd/nscd.c Modified: head/usr.sbin/nscd/nscd.c ============================================================================== --- head/usr.sbin/nscd/nscd.c Fri Oct 10 21:23:50 2008 (r183754) +++ head/usr.sbin/nscd/nscd.c Fri Oct 10 22:40:05 2008 (r183755) @@ -77,7 +77,6 @@ static void destroy_cache_(cache); static void destroy_runtime_env(struct runtime_env *); static cache init_cache_(struct configuration *); static struct runtime_env *init_runtime_env(struct configuration *); -static void print_version_info(void); static void processing_loop(cache, struct runtime_env *, struct configuration *); static void process_socket_event(struct kevent *, struct runtime_env *, @@ -90,14 +89,6 @@ static void usage(void); void get_time_func(struct timeval *); static void -print_version_info(void) -{ - TRACE_IN(print_version_info); - printf("nscd v0.2 (20 Oct 2005)\nwas developed during SoC 2005\n"); - TRACE_OUT(print_version_info); -} - -static void usage(void) { fprintf(stderr, @@ -622,9 +613,6 @@ main(int argc, char *argv[]) /* by default all debug messages are omitted */ TRACE_OFF(); - /* startup output */ - print_version_info(); - /* parsing command line arguments */ trace_mode_enabled = 0; force_single_threaded = 0; From bms at FreeBSD.org Sat Oct 11 02:26:05 2008 From: bms at FreeBSD.org (Bruce M. Simpson) Date: Sat Oct 11 02:26:15 2008 Subject: svn commit: r183735 - in head: share/man/man4 sys/conf sys/dev/usb sys/i386/conf sys/modules sys/modules/u3g In-Reply-To: <200810092125.m99LP1fJ071973@svn.freebsd.org> References: <200810092125.m99LP1fJ071973@svn.freebsd.org> Message-ID: <48F00ABA.2020300@FreeBSD.org> Nick Hibma wrote: > Log: > Say hello to the u3g driver, implementing support for 3G modems. > Thank you very, very much for doing this! I had stuff like this (add the multiple ports) on my list of "things to do" for ubsa, as obviously it isn't possible to cleanly shut down a connection without detaching the driver, which can be unreliable and unstable. Is it going to be possible to MFC this driver to 7.x? cheers BMS From rpaulo at FreeBSD.org Sat Oct 11 10:47:21 2008 From: rpaulo at FreeBSD.org (Rui Paulo) Date: Sat Oct 11 10:47:33 2008 Subject: svn commit: r183761 - head/sys/dev/usb Message-ID: <200810111047.m9BAlJ8Q016403@svn.freebsd.org> Author: rpaulo Date: Sat Oct 11 10:47:18 2008 New Revision: 183761 URL: http://svn.freebsd.org/changeset/base/183761 Log: Move Qualcomm ZTE CDMA from ubsa(4) to u3g(4). Reviewed by: n_hibma Modified: head/sys/dev/usb/u3g.c head/sys/dev/usb/ubsa.c Modified: head/sys/dev/usb/u3g.c ============================================================================== --- head/sys/dev/usb/u3g.c Sat Oct 11 02:01:51 2008 (r183760) +++ head/sys/dev/usb/u3g.c Sat Oct 11 10:47:18 2008 (r183761) @@ -89,6 +89,8 @@ static const struct usb_devno u3g_devs[] /* OEM: Huawei */ { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_MOBILE }, { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220 }, + /* OEM: Qualcomm */ + { USB_VENDOR_QUALCOMMINC, USB_PRODUCT_QUALCOMMINC_CDMA_MSM }, { 0, 0 } }; Modified: head/sys/dev/usb/ubsa.c ============================================================================== --- head/sys/dev/usb/ubsa.c Sat Oct 11 02:01:51 2008 (r183760) +++ head/sys/dev/usb/ubsa.c Sat Oct 11 10:47:18 2008 (r183761) @@ -228,8 +228,6 @@ static const struct ubsa_product { { USB_VENDOR_PERACOM, USB_PRODUCT_PERACOM_SERIAL1 }, /* Merlin */ { USB_VENDOR_MERLIN, USB_PRODUCT_MERLIN_V620 }, - /* Qualcomm, Inc. ZTE CDMA */ - { USB_VENDOR_QUALCOMMINC, USB_PRODUCT_QUALCOMMINC_CDMA_MSM }, /* Novatel */ { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_CDMA_MODEM }, /* Novatel Wireless Merlin ES620 */ From marius at FreeBSD.org Sat Oct 11 12:10:24 2008 From: marius at FreeBSD.org (Marius Strobl) Date: Sat Oct 11 12:10:35 2008 Subject: svn commit: r183762 - head/sys/sparc64/conf Message-ID: <200810111210.m9BCANYP017811@svn.freebsd.org> Author: marius Date: Sat Oct 11 12:10:23 2008 New Revision: 183762 URL: http://svn.freebsd.org/changeset/base/183762 Log: Enable mpt(4) as some later models have on-board Fusion-MPT controllers and it seems to work just fine with at least an add-on SAS3080X. While at it, remove the commented out ncr(4) as it doesn't even use bus_dma(9), which isn't worth fixing though as sym(4) already supports a superset of the controllers driven by ncr(4). Modified: head/sys/sparc64/conf/GENERIC Modified: head/sys/sparc64/conf/GENERIC ============================================================================== --- head/sys/sparc64/conf/GENERIC Sat Oct 11 10:47:18 2008 (r183761) +++ head/sys/sparc64/conf/GENERIC Sat Oct 11 12:10:23 2008 (r183762) @@ -106,9 +106,8 @@ options AHC_REG_PRETTY_PRINT # Print re # output. Adds ~128k to driver. device isp # Qlogic family device ispfw # Firmware module for Qlogic host adapters -#device mpt # LSI-Logic MPT-Fusion -#device ncr # NCR/Symbios Logic -device sym # NCR/Symbios Logic (newer chipsets + those of `ncr') +device mpt # LSI-Logic MPT-Fusion +device sym # NCR/Symbios/LSI Logic 53C8XX/53C1010/53C1510D device esp # NCR53c9x (FEPS/FAS366) # SCSI peripherals From mav at FreeBSD.org Sat Oct 11 13:05:14 2008 From: mav at FreeBSD.org (Alexander Motin) Date: Sat Oct 11 13:05:25 2008 Subject: svn commit: r183763 - head/sys/dev/mmc Message-ID: <200810111305.m9BD5DZs018778@svn.freebsd.org> Author: mav Date: Sat Oct 11 13:05:13 2008 New Revision: 183763 URL: http://svn.freebsd.org/changeset/base/183763 Log: Give mmcsd driver a bit more information about card. It allows to reorganize log message in a way a bit more common for disk devices. Also it will allow mmcsd driver to use MMC/SD specific commands when needed. Modified: head/sys/dev/mmc/mmc.c head/sys/dev/mmc/mmcsd.c head/sys/dev/mmc/mmcvar.h Modified: head/sys/dev/mmc/mmc.c ============================================================================== --- head/sys/dev/mmc/mmc.c Sat Oct 11 12:10:23 2008 (r183762) +++ head/sys/dev/mmc/mmc.c Sat Oct 11 13:05:13 2008 (r183763) @@ -115,6 +115,7 @@ static int mmc_detach(device_t dev); #define MMC_ASSERT_LOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_OWNED); #define MMC_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_NOTOWNED); +static int mmc_calculate_clock(struct mmc_softc *sc); static void mmc_delayed_attach(void *); static void mmc_power_down(struct mmc_softc *sc); static int mmc_wait_for_cmd(struct mmc_softc *sc, struct mmc_command *cmd, @@ -122,7 +123,7 @@ static int mmc_wait_for_cmd(struct mmc_s static int mmc_wait_for_command(struct mmc_softc *sc, uint32_t opcode, uint32_t arg, uint32_t flags, uint32_t *resp, int retries); static int mmc_select_card(struct mmc_softc *sc, uint16_t rca); -static int mmc_set_bus_width(struct mmc_softc *sc, uint16_t rca, int width); +static int mmc_set_card_bus_width(struct mmc_softc *sc, uint16_t rca, int width); static int mmc_app_send_scr(struct mmc_softc *sc, uint16_t rca, uint32_t *rawscr); static void mmc_app_decode_scr(uint32_t *raw_scr, struct mmc_scr *scr); static int mmc_send_ext_csd(struct mmc_softc *sc, uint8_t *rawextcsd); @@ -215,11 +216,13 @@ mmc_acquire_bus(device_t busdev, device_ sc->last_rca = rca; /* Prepare bus width for the new card. */ ivar = device_get_ivars(dev); - device_printf(busdev, - "setting bus width to %d bits\n", - (ivar->bus_width == bus_width_4)?4: - (ivar->bus_width == bus_width_8)?8:1); - mmc_set_bus_width(sc, rca, ivar->bus_width); + if (bootverbose) { + device_printf(busdev, + "setting bus width to %d bits\n", + (ivar->bus_width == bus_width_4)?4: + (ivar->bus_width == bus_width_8)?8:1); + } + mmc_set_card_bus_width(sc, rca, ivar->bus_width); mmcbr_set_bus_width(busdev, ivar->bus_width); mmcbr_update_ios(busdev); } @@ -571,7 +574,7 @@ mmc_sd_switch(struct mmc_softc *sc, uint } static int -mmc_set_bus_width(struct mmc_softc *sc, uint16_t rca, int width) +mmc_set_card_bus_width(struct mmc_softc *sc, uint16_t rca, int width) { int err; @@ -1167,6 +1170,7 @@ mmc_go_discovery(struct mmc_softc *sc) mmcbr_set_bus_mode(dev, pushpull); mmcbr_update_ios(dev); + mmc_calculate_clock(sc); bus_generic_attach(dev); /* mmc_update_children_sysctl(dev);*/ } @@ -1208,9 +1212,11 @@ mmc_calculate_clock(struct mmc_softc *sc free(kids, M_TEMP); if (max_timing == bus_timing_hs) max_dtr = max_hs_dtr; - device_printf(sc->dev, "setting transfer rate to %d.%03dMHz%s\n", - max_dtr / 1000000, (max_dtr / 1000) % 1000, - (max_timing == bus_timing_hs)?" with high speed timing":""); + if (bootverbose) { + device_printf(sc->dev, "setting transfer rate to %d.%03dMHz%s\n", + max_dtr / 1000000, (max_dtr / 1000) % 1000, + (max_timing == bus_timing_hs)?" with high speed timing":""); + } mmcbr_set_timing(sc->dev, max_timing); mmcbr_set_clock(sc->dev, max_dtr); mmcbr_update_ios(sc->dev); @@ -1228,7 +1234,6 @@ mmc_scan(struct mmc_softc *sc) if (mmcbr_get_power_mode(dev) == power_on) mmc_rescan_cards(sc); mmc_go_discovery(sc); - mmc_calculate_clock(sc); mmc_release_bus(dev, dev); /* XXX probe/attach/detach children? */ @@ -1255,7 +1260,7 @@ mmc_read_ivar(device_t bus, device_t chi *(int *)result = MMC_SECTOR_SIZE; break; case MMC_IVAR_TRAN_SPEED: - *(int *)result = ivar->csd.tran_speed; + *(int *)result = mmcbr_get_clock(bus); break; case MMC_IVAR_READ_ONLY: *(int *)result = ivar->read_only; @@ -1263,6 +1268,12 @@ mmc_read_ivar(device_t bus, device_t chi case MMC_IVAR_HIGH_CAP: *(int *)result = ivar->high_cap; break; + case MMC_IVAR_CARD_TYPE: + *(int *)result = ivar->mode; + break; + case MMC_IVAR_BUS_WIDTH: + *(int *)result = ivar->bus_width; + break; } return (0); } Modified: head/sys/dev/mmc/mmcsd.c ============================================================================== --- head/sys/dev/mmc/mmcsd.c Sat Oct 11 12:10:23 2008 (r183762) +++ head/sys/dev/mmc/mmcsd.c Sat Oct 11 13:05:13 2008 (r183763) @@ -133,10 +133,15 @@ mmcsd_attach(device_t dev) mmc_get_sector_size(dev); sc->disk->d_unit = device_get_unit(dev); - device_printf(dev, "%juMB %s at %s\n", + device_printf(dev, "%juMB <%s Memory Card>%s at %s %dMHz/%dbit\n", sc->disk->d_mediasize / 1048576, + (mmc_get_card_type(dev) == mode_mmc)?"MMC": + (mmc_get_high_cap(dev)?"SDHC":"SD"), mmc_get_read_only(dev)?" (read-only)":"", - device_get_nameunit(device_get_parent(sc->dev))); + device_get_nameunit(device_get_parent(sc->dev)), + mmc_get_tran_speed(dev)/1000000, + (mmc_get_bus_width(dev) == bus_width_1)?1: + ((mmc_get_bus_width(dev) == bus_width_4)?4:8)); disk_create(sc->disk, DISK_VERSION); bioq_init(&sc->bio_queue); Modified: head/sys/dev/mmc/mmcvar.h ============================================================================== --- head/sys/dev/mmc/mmcvar.h Sat Oct 11 12:10:23 2008 (r183762) +++ head/sys/dev/mmc/mmcvar.h Sat Oct 11 13:05:13 2008 (r183763) @@ -55,6 +55,8 @@ #ifndef DEV_MMC_MMCVAR_H #define DEV_MMC_MMCVAR_H +#include + enum mmc_device_ivars { MMC_IVAR_DSR_IMP, MMC_IVAR_MEDIA_SIZE, @@ -63,6 +65,8 @@ enum mmc_device_ivars { MMC_IVAR_TRAN_SPEED, MMC_IVAR_READ_ONLY, MMC_IVAR_HIGH_CAP, + MMC_IVAR_CARD_TYPE, + MMC_IVAR_BUS_WIDTH, // MMC_IVAR_, }; @@ -79,5 +83,7 @@ MMC_ACCESSOR(sector_size, SECTOR_SIZE, i MMC_ACCESSOR(tran_speed, TRAN_SPEED, int) MMC_ACCESSOR(read_only, READ_ONLY, int) MMC_ACCESSOR(high_cap, HIGH_CAP, int) +MMC_ACCESSOR(card_type, CARD_TYPE, int) +MMC_ACCESSOR(bus_width, BUS_WIDTH, int) #endif /* DEV_MMC_MMCVAR_H */ From rwatson at FreeBSD.org Sat Oct 11 17:28:23 2008 From: rwatson at FreeBSD.org (Robert Watson) Date: Sat Oct 11 17:28:34 2008 Subject: svn commit: r183764 - head/sys/kern Message-ID: <200810111728.m9BHSNCo023106@svn.freebsd.org> Author: rwatson Date: Sat Oct 11 17:28:22 2008 New Revision: 183764 URL: http://svn.freebsd.org/changeset/base/183764 Log: Remove stale comment: while uipc_connect2() was, until recently, not static so it could be used by fifofs (actually portalfs), it is now static. Submitted by: kensmith Modified: head/sys/kern/uipc_usrreq.c Modified: head/sys/kern/uipc_usrreq.c ============================================================================== --- head/sys/kern/uipc_usrreq.c Sat Oct 11 13:05:13 2008 (r183763) +++ head/sys/kern/uipc_usrreq.c Sat Oct 11 17:28:22 2008 (r183764) @@ -529,9 +529,6 @@ uipc_close(struct socket *so) UNP_GLOBAL_WUNLOCK(); } -/* - * uipc_connect2() is not static as it is invoked directly by fifofs. - */ static int uipc_connect2(struct socket *so1, struct socket *so2) { From mav at FreeBSD.org Sat Oct 11 17:30:02 2008 From: mav at FreeBSD.org (Alexander Motin) Date: Sat Oct 11 17:30:09 2008 Subject: svn commit: r183765 - head/sys/dev/mmc Message-ID: <200810111730.m9BHU2u1023174@svn.freebsd.org> Author: mav Date: Sat Oct 11 17:30:02 2008 New Revision: 183765 URL: http://svn.freebsd.org/changeset/base/183765 Log: SELECT_CARD command with zero RCA deselects all cards and so has no reply. Modified: head/sys/dev/mmc/mmc.c Modified: head/sys/dev/mmc/mmc.c ============================================================================== --- head/sys/dev/mmc/mmc.c Sat Oct 11 17:28:22 2008 (r183764) +++ head/sys/dev/mmc/mmc.c Sat Oct 11 17:30:02 2008 (r183765) @@ -526,7 +526,7 @@ static int mmc_select_card(struct mmc_softc *sc, uint16_t rca) { return (mmc_wait_for_command(sc, MMC_SELECT_CARD, ((uint32_t)rca) << 16, - MMC_RSP_R1B | MMC_CMD_AC, NULL, CMD_RETRIES)); + (rca?MMC_RSP_R1B:MMC_RSP_NONE) | MMC_CMD_AC, NULL, CMD_RETRIES)); } static int From delphij at FreeBSD.org Sun Oct 12 00:44:28 2008 From: delphij at FreeBSD.org (Xin LI) Date: Sun Oct 12 00:44:35 2008 Subject: svn commit: r183770 - head/usr.sbin/nscd Message-ID: <200810120044.m9C0iRUt031013@svn.freebsd.org> Author: delphij Date: Sun Oct 12 00:44:27 2008 New Revision: 183770 URL: http://svn.freebsd.org/changeset/base/183770 Log: Reduce code duplication: use calloc instead of allocing and memset afterward. Approved by: bushman Modified: head/usr.sbin/nscd/agent.c head/usr.sbin/nscd/cachelib.c head/usr.sbin/nscd/cacheplcs.c head/usr.sbin/nscd/config.c head/usr.sbin/nscd/hashtable.h head/usr.sbin/nscd/mp_rs_query.c head/usr.sbin/nscd/mp_ws_query.c head/usr.sbin/nscd/nscd.c head/usr.sbin/nscd/nscdcli.c head/usr.sbin/nscd/query.c Modified: head/usr.sbin/nscd/agent.c ============================================================================== --- head/usr.sbin/nscd/agent.c Sat Oct 11 21:59:03 2008 (r183769) +++ head/usr.sbin/nscd/agent.c Sun Oct 12 00:44:27 2008 (r183770) @@ -60,9 +60,8 @@ init_agent_table() struct agent_table *retval; TRACE_IN(init_agent_table); - retval = (struct agent_table *)malloc(sizeof(struct agent_table)); + retval = (struct agent_table *)calloc(1, sizeof(struct agent_table)); assert(retval != NULL); - memset(retval, 0, sizeof(struct agent_table)); TRACE_OUT(init_agent_table); return (retval); Modified: head/usr.sbin/nscd/cachelib.c ============================================================================== --- head/usr.sbin/nscd/cachelib.c Sat Oct 11 21:59:03 2008 (r183769) +++ head/usr.sbin/nscd/cachelib.c Sun Oct 12 00:44:27 2008 (r183770) @@ -479,18 +479,15 @@ init_cache(struct cache_params const *pa TRACE_IN(init_cache); assert(params != NULL); - retval = (struct cache_ *)malloc(sizeof(struct cache_)); + retval = (struct cache_ *)calloc(1, sizeof(struct cache_)); assert(retval != NULL); - memset(retval, 0, sizeof(struct cache_)); assert(params != NULL); memcpy(&retval->params, params, sizeof(struct cache_params)); - retval->entries = (struct cache_entry_ **)malloc( + retval->entries = (struct cache_entry_ **)calloc(1, sizeof(struct cache_entry_ *) * INITIAL_ENTRIES_CAPACITY); assert(retval->entries != NULL); - memset(retval->entries, 0, sizeof(sizeof(struct cache_entry_ *) - * INITIAL_ENTRIES_CAPACITY)); retval->entries_capacity = INITIAL_ENTRIES_CAPACITY; retval->entries_size = 0; @@ -541,12 +538,10 @@ register_cache_entry(struct cache_ *the_ new_capacity = the_cache->entries_capacity + ENTRIES_CAPACITY_STEP; - new_entries = (struct cache_entry_ **)malloc( + new_entries = (struct cache_entry_ **)calloc(1, sizeof(struct cache_entry_ *) * new_capacity); assert(new_entries != NULL); - memset(new_entries, 0, sizeof(struct cache_entry_ *) * - new_capacity); memcpy(new_entries, the_cache->entries, sizeof(struct cache_entry_ *) * the_cache->entries_size); @@ -559,21 +554,18 @@ register_cache_entry(struct cache_ *the_ switch (params->entry_type) { case CET_COMMON: - new_common_entry = (struct cache_common_entry_ *)malloc( + new_common_entry = (struct cache_common_entry_ *)calloc(1, sizeof(struct cache_common_entry_)); assert(new_common_entry != NULL); - memset(new_common_entry, 0, sizeof(struct cache_common_entry_)); memcpy(&new_common_entry->common_params, params, sizeof(struct common_cache_entry_params)); new_common_entry->params = (struct cache_entry_params *)&new_common_entry->common_params; - new_common_entry->common_params.entry_name = (char *)malloc( + new_common_entry->common_params.entry_name = (char *)calloc(1, entry_name_size+1); assert(new_common_entry->common_params.entry_name != NULL); - memset(new_common_entry->common_params.entry_name, 0, - entry_name_size + 1); strncpy(new_common_entry->common_params.entry_name, params->entry_name, entry_name_size); new_common_entry->name = @@ -588,11 +580,9 @@ register_cache_entry(struct cache_ *the_ else policies_size = 2; - new_common_entry->policies = (struct cache_policy_ **)malloc( + new_common_entry->policies = (struct cache_policy_ **)calloc(1, sizeof(struct cache_policy_ *) * policies_size); assert(new_common_entry->policies != NULL); - memset(new_common_entry->policies, 0, - sizeof(struct cache_policy_ *) * policies_size); new_common_entry->policies_size = policies_size; new_common_entry->policies[0] = init_cache_fifo_policy(); @@ -618,21 +608,18 @@ register_cache_entry(struct cache_ *the_ (struct cache_entry_ *)new_common_entry; break; case CET_MULTIPART: - new_mp_entry = (struct cache_mp_entry_ *)malloc( + new_mp_entry = (struct cache_mp_entry_ *)calloc(1, sizeof(struct cache_mp_entry_)); assert(new_mp_entry != NULL); - memset(new_mp_entry, 0, sizeof(struct cache_mp_entry_)); memcpy(&new_mp_entry->mp_params, params, sizeof(struct mp_cache_entry_params)); new_mp_entry->params = (struct cache_entry_params *)&new_mp_entry->mp_params; - new_mp_entry->mp_params.entry_name = (char *)malloc( + new_mp_entry->mp_params.entry_name = (char *)calloc(1, entry_name_size+1); assert(new_mp_entry->mp_params.entry_name != NULL); - memset(new_mp_entry->mp_params.entry_name, 0, - entry_name_size + 1); strncpy(new_mp_entry->mp_params.entry_name, params->entry_name, entry_name_size); new_mp_entry->name = new_mp_entry->mp_params.entry_name; @@ -925,10 +912,9 @@ open_cache_mp_write_session(struct cache return (NULL); } - retval = (struct cache_mp_write_session_ *)malloc( + retval = (struct cache_mp_write_session_ *)calloc(1, sizeof(struct cache_mp_write_session_)); assert(retval != NULL); - memset(retval, 0, sizeof(struct cache_mp_write_session_)); TAILQ_INIT(&retval->items); retval->parent_entry = mp_entry; @@ -961,10 +947,9 @@ cache_mp_write(struct cache_mp_write_ses return (-1); } - new_item = (struct cache_mp_data_item_ *)malloc( + new_item = (struct cache_mp_data_item_ *)calloc(1, sizeof(struct cache_mp_data_item_)); assert(new_item != NULL); - memset(new_item, 0, sizeof(struct cache_mp_data_item_)); new_item->value = (char *)malloc(data_size); assert(new_item->value != NULL); @@ -1065,10 +1050,9 @@ open_cache_mp_read_session(struct cache_ } } - retval = (struct cache_mp_read_session_ *)malloc( + retval = (struct cache_mp_read_session_ *)calloc(1, sizeof(struct cache_mp_read_session_)); assert(retval != NULL); - memset(retval, 0, sizeof(struct cache_mp_read_session_)); retval->parent_entry = mp_entry; retval->current_item = TAILQ_FIRST( Modified: head/usr.sbin/nscd/cacheplcs.c ============================================================================== --- head/usr.sbin/nscd/cacheplcs.c Sat Oct 11 21:59:03 2008 (r183769) +++ head/usr.sbin/nscd/cacheplcs.c Sun Oct 12 00:44:27 2008 (r183770) @@ -82,10 +82,9 @@ cache_queue_policy_create_item() struct cache_queue_policy_item_ *retval; TRACE_IN(cache_queue_policy_create_item); - retval = (struct cache_queue_policy_item_ *)malloc( + retval = (struct cache_queue_policy_item_ *)calloc(1, sizeof(struct cache_queue_policy_item_)); assert(retval != NULL); - memset(retval, 0, sizeof(struct cache_queue_policy_item_)); TRACE_OUT(cache_queue_policy_create_item); return ((struct cache_policy_item_ *)retval); @@ -193,10 +192,9 @@ init_cache_queue_policy(void) struct cache_queue_policy_ *retval; TRACE_IN(init_cache_queue_policy); - retval = (struct cache_queue_policy_ *)malloc( + retval = (struct cache_queue_policy_ *)calloc(1, sizeof(struct cache_queue_policy_)); assert(retval != NULL); - memset(retval, 0, sizeof(struct cache_queue_policy_)); retval->parent_data.create_item_func = cache_queue_policy_create_item; retval->parent_data.destroy_item_func = cache_queue_policy_destroy_item; @@ -334,10 +332,9 @@ cache_lfu_policy_create_item(void) struct cache_lfu_policy_item_ *retval; TRACE_IN(cache_lfu_policy_create_item); - retval = (struct cache_lfu_policy_item_ *)malloc( + retval = (struct cache_lfu_policy_item_ *)calloc(1, sizeof(struct cache_lfu_policy_item_)); assert(retval != NULL); - memset(retval, 0, sizeof(struct cache_lfu_policy_item_)); TRACE_OUT(cache_lfu_policy_create_item); return ((struct cache_policy_item_ *)retval); @@ -539,10 +536,9 @@ init_cache_lfu_policy() struct cache_lfu_policy_ *retval; TRACE_IN(init_cache_lfu_policy); - retval = (struct cache_lfu_policy_ *)malloc( + retval = (struct cache_lfu_policy_ *)calloc(1, sizeof(struct cache_lfu_policy_)); assert(retval != NULL); - memset(retval, 0, sizeof(struct cache_lfu_policy_)); retval->parent_data.create_item_func = cache_lfu_policy_create_item; retval->parent_data.destroy_item_func = cache_lfu_policy_destroy_item; Modified: head/usr.sbin/nscd/config.c ============================================================================== --- head/usr.sbin/nscd/config.c Sat Oct 11 21:59:03 2008 (r183769) +++ head/usr.sbin/nscd/config.c Sun Oct 12 00:44:27 2008 (r183770) @@ -119,10 +119,9 @@ create_configuration_entry(const char *n assert(negative_params != NULL); assert(mp_params != NULL); - retval = (struct configuration_entry *)malloc( + retval = (struct configuration_entry *)calloc(1, sizeof(struct configuration_entry)); assert(retval != NULL); - memset(retval, 0, sizeof(struct configuration_entry)); res = pthread_mutex_init(&retval->positive_cache_lock, NULL); if (res != 0) { @@ -162,9 +161,8 @@ create_configuration_entry(const char *n sizeof(struct mp_cache_entry_params)); size = strlen(name); - retval->name = (char *)malloc(size + 1); + retval->name = (char *)calloc(1, size + 1); assert(retval->name != NULL); - memset(retval->name, 0, size + 1); memcpy(retval->name, name, size); memcpy(&retval->common_query_timeout, common_timeout, @@ -268,12 +266,10 @@ add_configuration_entry(struct configura struct configuration_entry **new_entries; config->entries_capacity *= 2; - new_entries = (struct configuration_entry **)malloc( + new_entries = (struct configuration_entry **)calloc(1, sizeof(struct configuration_entry *) * config->entries_capacity); assert(new_entries != NULL); - memset(new_entries, 0, sizeof(struct configuration_entry *) * - config->entries_capacity); memcpy(new_entries, config->entries, sizeof(struct configuration_entry *) * config->entries_size); @@ -514,17 +510,14 @@ init_configuration(void) struct configuration *retval; TRACE_IN(init_configuration); - retval = (struct configuration *)malloc(sizeof(struct configuration)); + retval = (struct configuration *)calloc(1, sizeof(struct configuration)); assert(retval != NULL); - memset(retval, 0, sizeof(struct configuration)); retval->entries_capacity = INITIAL_ENTRIES_CAPACITY; - retval->entries = (struct configuration_entry **)malloc( + retval->entries = (struct configuration_entry **)calloc(1, sizeof(struct configuration_entry *) * retval->entries_capacity); assert(retval->entries != NULL); - memset(retval->entries, 0, sizeof(struct configuration_entry *) * - retval->entries_capacity); pthread_rwlock_init(&retval->rwlock, NULL); @@ -544,15 +537,13 @@ fill_configuration_defaults(struct confi free(config->socket_path); len = strlen(DEFAULT_SOCKET_PATH); - config->socket_path = (char *)malloc(len + 1); + config->socket_path = (char *)calloc(1, len + 1); assert(config->socket_path != NULL); - memset(config->socket_path, 0, len + 1); memcpy(config->socket_path, DEFAULT_SOCKET_PATH, len); len = strlen(DEFAULT_PIDFILE_PATH); - config->pidfile_path = (char *)malloc(len + 1); + config->pidfile_path = (char *)calloc(1, len + 1); assert(config->pidfile_path != NULL); - memset(config->pidfile_path, 0, len + 1); memcpy(config->pidfile_path, DEFAULT_PIDFILE_PATH, len); config->socket_mode = S_IFSOCK | S_IRUSR | S_IWUSR | Modified: head/usr.sbin/nscd/hashtable.h ============================================================================== --- head/usr.sbin/nscd/hashtable.h Sat Oct 11 21:59:03 2008 (r183769) +++ head/usr.sbin/nscd/hashtable.h Sun Oct 12 00:44:27 2008 (r183770) @@ -75,9 +75,7 @@ typedef int hashtable_index_t; #define HASHTABLE_INIT(table, type, field, _entries_size) \ do { \ hashtable_index_t var; \ - (table)->entries = (void *)malloc( \ - sizeof(*(table)->entries) * (_entries_size)); \ - memset((table)->entries, 0, \ + (table)->entries = (void *)calloc(1, \ sizeof(*(table)->entries) * (_entries_size)); \ (table)->entries_size = (_entries_size); \ for (var = 0; var < HASHTABLE_ENTRIES_COUNT(table); ++var) {\ Modified: head/usr.sbin/nscd/mp_rs_query.c ============================================================================== --- head/usr.sbin/nscd/mp_rs_query.c Sat Oct 11 21:59:03 2008 (r183769) +++ head/usr.sbin/nscd/mp_rs_query.c Sun Oct 12 00:44:27 2008 (r183770) @@ -115,11 +115,9 @@ on_mp_read_session_request_read1(struct return (-1); } - c_mp_rs_request->entry = (char *)malloc( + c_mp_rs_request->entry = (char *)calloc(1, c_mp_rs_request->entry_length + 1); assert(c_mp_rs_request->entry != NULL); - memset(c_mp_rs_request->entry, 0, - c_mp_rs_request->entry_length + 1); qstate->kevent_watermark = c_mp_rs_request->entry_length; qstate->process_func = on_mp_read_session_request_read2; Modified: head/usr.sbin/nscd/mp_ws_query.c ============================================================================== --- head/usr.sbin/nscd/mp_ws_query.c Sat Oct 11 21:59:03 2008 (r183769) +++ head/usr.sbin/nscd/mp_ws_query.c Sun Oct 12 00:44:27 2008 (r183770) @@ -121,11 +121,9 @@ on_mp_write_session_request_read1(struct return (-1); } - c_mp_ws_request->entry = (char *)malloc( + c_mp_ws_request->entry = (char *)calloc(1, c_mp_ws_request->entry_length + 1); assert(c_mp_ws_request->entry != NULL); - memset(c_mp_ws_request->entry, 0, - c_mp_ws_request->entry_length + 1); qstate->kevent_watermark = c_mp_ws_request->entry_length; qstate->process_func = on_mp_write_session_request_read2; @@ -376,9 +374,8 @@ on_mp_write_session_write_request_read1( return (-1); } - write_request->data = (char *)malloc(write_request->data_size); + write_request->data = (char *)calloc(1, write_request->data_size); assert(write_request->data != NULL); - memset(write_request->data, 0, write_request->data_size); qstate->kevent_watermark = write_request->data_size; qstate->process_func = on_mp_write_session_write_request_read2; Modified: head/usr.sbin/nscd/nscd.c ============================================================================== --- head/usr.sbin/nscd/nscd.c Sat Oct 11 21:59:03 2008 (r183769) +++ head/usr.sbin/nscd/nscd.c Sun Oct 12 00:44:27 2008 (r183770) @@ -163,9 +163,8 @@ init_runtime_env(struct configuration *c struct runtime_env *retval; TRACE_IN(init_runtime_env); - retval = (struct runtime_env *)malloc(sizeof(struct runtime_env)); + retval = (struct runtime_env *)calloc(1, sizeof(struct runtime_env)); assert(retval != NULL); - memset(retval, 0, sizeof(struct runtime_env)); retval->sockfd = socket(PF_LOCAL, SOCK_STREAM, 0); @@ -408,10 +407,9 @@ process_socket_event(struct kevent *even if (qstate->io_buffer != NULL) free(qstate->io_buffer); - qstate->io_buffer = (char *)malloc( + qstate->io_buffer = (char *)calloc(1, qstate->kevent_watermark); assert(qstate->io_buffer != NULL); - memset(qstate->io_buffer, 0, qstate->kevent_watermark); qstate->io_buffer_p = qstate->io_buffer; qstate->io_buffer_size = qstate->kevent_watermark; @@ -829,10 +827,8 @@ main(int argc, char *argv[]) } if (s_configuration->threads_num > 1) { - threads = (pthread_t *)malloc(sizeof(pthread_t) * + threads = (pthread_t *)calloc(1, sizeof(pthread_t) * s_configuration->threads_num); - memset(threads, 0, sizeof(pthread_t) * - s_configuration->threads_num); for (i = 0; i < s_configuration->threads_num; ++i) { thread_args = (struct processing_thread_args *)malloc( sizeof(struct processing_thread_args)); Modified: head/usr.sbin/nscd/nscdcli.c ============================================================================== --- head/usr.sbin/nscd/nscdcli.c Sat Oct 11 21:59:03 2008 (r183769) +++ head/usr.sbin/nscd/nscdcli.c Sun Oct 12 00:44:27 2008 (r183770) @@ -201,9 +201,8 @@ open_nscd_connection__(struct nscd_conne } fcntl(client_socket, F_SETFL, O_NONBLOCK); - retval = malloc(sizeof(struct nscd_connection_)); + retval = calloc(1, sizeof(struct nscd_connection_)); assert(retval != NULL); - memset(retval, 0, sizeof(struct nscd_connection_)); retval->sockfd = client_socket; Modified: head/usr.sbin/nscd/query.c ============================================================================== --- head/usr.sbin/nscd/query.c Sat Oct 11 21:59:03 2008 (r183769) +++ head/usr.sbin/nscd/query.c Sun Oct 12 00:44:27 2008 (r183770) @@ -332,27 +332,21 @@ on_write_request_read1(struct query_stat return (-1); } - write_request->entry = (char *)malloc( + write_request->entry = (char *)calloc(1, write_request->entry_length + 1); assert(write_request->entry != NULL); - memset(write_request->entry, 0, - write_request->entry_length + 1); - write_request->cache_key = (char *)malloc( + write_request->cache_key = (char *)calloc(1, write_request->cache_key_size + qstate->eid_str_length); assert(write_request->cache_key != NULL); memcpy(write_request->cache_key, qstate->eid_str, qstate->eid_str_length); - memset(write_request->cache_key + qstate->eid_str_length, 0, - write_request->cache_key_size); if (write_request->data_size != 0) { - write_request->data = (char *)malloc( + write_request->data = (char *)calloc(1, write_request->data_size); assert(write_request->data != NULL); - memset(write_request->data, 0, - write_request->data_size); } qstate->kevent_watermark = write_request->entry_length + @@ -611,19 +605,16 @@ on_read_request_read1(struct query_state return (-1); } - read_request->entry = (char *)malloc( + read_request->entry = (char *)calloc(1, read_request->entry_length + 1); assert(read_request->entry != NULL); - memset(read_request->entry, 0, read_request->entry_length + 1); - read_request->cache_key = (char *)malloc( + read_request->cache_key = (char *)calloc(1, read_request->cache_key_size + qstate->eid_str_length); assert(read_request->cache_key != NULL); memcpy(read_request->cache_key, qstate->eid_str, qstate->eid_str_length); - memset(read_request->cache_key + qstate->eid_str_length, 0, - read_request->cache_key_size); qstate->kevent_watermark = read_request->entry_length + read_request->cache_key_size; @@ -936,11 +927,9 @@ on_transform_request_read1(struct query_ return (-1); } - transform_request->entry = (char *)malloc( + transform_request->entry = (char *)calloc(1, transform_request->entry_length + 1); assert(transform_request->entry != NULL); - memset(transform_request->entry, 0, - transform_request->entry_length + 1); qstate->process_func = on_transform_request_read2; } else @@ -1228,9 +1217,8 @@ init_query_state(int sockfd, size_t keve struct query_state *retval; TRACE_IN(init_query_state); - retval = (struct query_state *)malloc(sizeof(struct query_state)); + retval = (struct query_state *)calloc(1, sizeof(struct query_state)); assert(retval != NULL); - memset(retval, 0, sizeof(struct query_state)); retval->sockfd = sockfd; retval->kevent_filter = EVFILT_READ; From imp at FreeBSD.org Sun Oct 12 02:31:09 2008 From: imp at FreeBSD.org (Warner Losh) Date: Sun Oct 12 02:31:15 2008 Subject: svn commit: r183771 - head/sys/mips/mips Message-ID: <200810120231.m9C2V9hc032807@svn.freebsd.org> Author: imp Date: Sun Oct 12 02:31:09 2008 New Revision: 183771 URL: http://svn.freebsd.org/changeset/base/183771 Log: opt_msgbuf.h is needed for MSGBUF_SIZE overrides, if any. Submitted by: alc@ Modified: head/sys/mips/mips/machdep.c head/sys/mips/mips/pmap.c Modified: head/sys/mips/mips/machdep.c ============================================================================== --- head/sys/mips/mips/machdep.c Sun Oct 12 00:44:27 2008 (r183770) +++ head/sys/mips/mips/machdep.c Sun Oct 12 02:31:09 2008 (r183771) @@ -42,8 +42,9 @@ #include __FBSDID("$FreeBSD$"); -#include "opt_md.h" #include "opt_ddb.h" +#include "opt_md.h" +#include "opt_msgbuf.h" #include #include Modified: head/sys/mips/mips/pmap.c ============================================================================== --- head/sys/mips/mips/pmap.c Sun Oct 12 00:44:27 2008 (r183770) +++ head/sys/mips/mips/pmap.c Sun Oct 12 02:31:09 2008 (r183771) @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include "opt_ddb.h" +#include "opt_msgbuf.h" #include #include #include From kensmith at FreeBSD.org Sun Oct 12 02:52:57 2008 From: kensmith at FreeBSD.org (Ken Smith) Date: Sun Oct 12 02:53:09 2008 Subject: svn commit: r183772 - head/release Message-ID: <200810120252.m9C2qvr9033190@svn.freebsd.org> Author: kensmith Date: Sun Oct 12 02:52:56 2008 New Revision: 183772 URL: http://svn.freebsd.org/changeset/base/183772 Log: Add a build knob MAKE_DVD to control on a per-architecture basis whether or not to build a tree used for the creation of a DVD image. If that is enabled set up a DVD tree by installing everything we normally install to the individual CDROM trees into the one DVD tree. The result is one image with all the install bits, livefs bits, and doc bits suitable for burning to a DVD instead of CDROM. Enable building the DVD for amd64 and i386. MFC after: 1 week Modified: head/release/Makefile Modified: head/release/Makefile ============================================================================== --- head/release/Makefile Sun Oct 12 02:31:09 2008 (r183771) +++ head/release/Makefile Sun Oct 12 02:52:56 2008 (r183772) @@ -192,6 +192,7 @@ MNT= /mnt .undef MAKE_FLOPPIES .if ${TARGET_ARCH} == "i386" MAKE_FLOPPIES= true +MAKE_DVD= SEPARATE_LIVEFS= SPLIT_MFSROOT= .if ${TARGET} == "pc98" @@ -222,6 +223,7 @@ MFSLABEL= auto SEPARATE_LIVEFS= .elif ${TARGET_ARCH} == "amd64" MAKE_FLOPPIES= true +MAKE_DVD= FLOPPYSIZE= 1440 FLOPPYSPLITSIZE= 1392 FLOPPYINODE= 40000 @@ -262,6 +264,9 @@ CD= ${_R}/cdrom CD_BOOT= ${CD}/bootonly CD_DISC1= ${CD}/disc1 CD_DISC2= ${CD}/disc2 +.if defined(MAKE_DVD) +CD_DVD= ${CD}/dvd +.endif .if !defined(NODOC) CD_DOCS= ${CD}/docs .endif @@ -480,6 +485,7 @@ release rerelease: KERNELS \ KERNELS_BASE \ KERNEL_FLAGS \ + MAKE_DVD \ MAKE_FLOPPIES \ MAKE_ISOS \ NOCDROM \ @@ -922,6 +928,18 @@ cdrom.1: find . -depth -print | cpio -dumpl ${CD_LIVEFS} ) ; \ fi \ done +.if defined(MAKE_DVD) + @echo "Building DVD filesystem image as well as CDROM" + @mkdir -p ${CD_DVD}/${BUILDNAME} + @for i in ${DISTRIBUTIONS} ; \ + do \ + if [ -d ${RD}/trees/$${i} ] ; then \ + chflags -R noschg ${RD}/trees/$${i} || true ; \ + ( cd ${RD}/trees/$${i} && \ + find . -depth -print | cpio -dumpl ${CD_DVD} ) ; \ + fi \ + done +.endif @echo "Copy GENERIC kernel to boot area" @cp -Rp ${RD}/kernels/GENERIC/ ${CD_LIVEFS}/boot/kernel @rm -f ${CD_LIVEFS}/boot/kernel/*.symbols @@ -939,7 +957,24 @@ cdrom.1: @rm -f ${CD_LIVEFS}/boot/device.hints @cp ${RD}/trees/base/boot/device.hints ${CD_LIVEFS}/boot/device.hints .endif +.if defined(MAKE_DVD) + @cp -Rp ${RD}/kernels/GENERIC/ ${CD_DVD}/boot/kernel + @rm -f ${CD_DVD}/boot/kernel/*.symbols + @rm -f ${CD_DVD}/.profile + @cp ${.CURDIR}/fixit.profile ${CD_DVD}/.profile + @ln -sf /rescue ${CD_DVD}/stand @echo "CD_VERSION = ${BUILDNAME}" > ${CD_LIVEFS}/cdrom.inf + @echo "CD_VERSION = ${BUILDNAME}" > ${CD_DVD}/cdrom.inf + @rm -f ${CD_DVD}/boot/loader.conf + @cp ${RD}/mfsroot/mfsroot.gz ${CD_DVD}/boot/mfsroot.gz + @echo 'mfsroot_load="YES"' > ${CD_DVD}/boot/loader.conf + @echo 'mfsroot_type="mfs_root"' >> ${CD_DVD}/boot/loader.conf + @echo 'mfsroot_name="/boot/mfsroot"' >> ${CD_DVD}/boot/loader.conf +.if exists(${RD}/trees/base/boot/device.hints) + @rm -f ${CD_DVD}/boot/device.hints + @cp ${RD}/trees/base/boot/device.hints ${CD_DVD}/boot/device.hints +.endif +.endif touch ${.TARGET} # Build disc1 and disc2 cdrom images @@ -974,11 +1009,37 @@ cdrom.2: @mkdir -p ${CD_DISC2} @echo "CD_VERSION = ${BUILDNAME}" > ${CD_DISC2}/cdrom.inf @echo "CD_VOLUME = 2" >> ${CD_DISC2}/cdrom.inf +.if defined(MAKE_DVD) +.if defined(MAKE_FLOPPIES) + @cd ${RD} && find floppies -print | cpio -dumpl ${CD_DVD} +.endif + @cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DVD}/${BUILDNAME} +.if !defined(NODOC) + @for i in ${DIST_DOCS_ARCH_INDEP}; do \ + cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \ + ${CD_DVD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \ + cp ${RND}/${RELNOTES_LANG}/$$i/article.html \ + ${CD_DVD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \ + done + @for i in ${DIST_DOCS_ARCH_DEP}; do \ + cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \ + ${CD_DVD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \ + cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html \ + ${CD_DVD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \ + done + @cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${CD_DVD} +.endif + @echo "CD_VERSION = ${BUILDNAME}" > ${CD_DVD}/cdrom.inf + @echo "CD_VOLUME = 1" >> ${CD_DVD}/cdrom.inf +.endif .if !defined(NODOC) echo "Building CDROM docs filesystem image" @mkdir -p ${CD_DOCS} @echo "CD_VERSION = ${BUILDNAME}" > ${CD_DOCS}/cdrom.inf @mkdir -p ${CD_DOCS}/usr/share/doc +.if defined(MAKE_DVD) + @mkdir -p ${CD_DVD}/usr/share/doc +.endif @for i in `ls ${CD_LIVEFS}/usr/share/doc`; do \ if [ -L ${CD_LIVEFS}/usr/share/doc/$$i -o \ -d /usr/doc/$$i ]; then \ @@ -986,6 +1047,10 @@ cdrom.2: ${CD_DOCS}/usr/share/doc; \ fi \ done +.if defined(MAKE_DVD) + @cd ${CD_DOCS}/usr/share/doc && find . -print | \ + cpio -dumpl ${CD_DVD}/usr/share/doc +.endif .endif touch ${.TARGET} @@ -1016,6 +1081,9 @@ CD_DISC1_PKGS= ${CD_PACKAGE_TREE}/disc1 .if exists(${CD_PACKAGE_TREE}/disc2) CD_DISC2_PKGS= ${CD_PACKAGE_TREE}/disc2 .endif +.if exists(${CD_PACKAGE_TREE}/dvd) +CD_DVD_PKGS= ${CD_PACKAGE_TREE}/dvd +.endif .endif .endif @@ -1035,6 +1103,12 @@ iso.1: FreeBSD_Packages \ ${CD}/${BUILDNAME}-${TARGET}-disc2.iso ${CD_DISC2} \ ${CD_DISC2_PKGS} +.if defined(MAKE_DVD) + @sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \ + FreeBSD_Install \ + ${CD}/${BUILDNAME}-${TARGET}-dvd.iso ${CD_DVD} \ + ${CD_DVD_PKGS} +.endif .if !defined(NODOC) @sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh \ FreeBSD_Documentation \ From imp at FreeBSD.org Sun Oct 12 06:58:04 2008 From: imp at FreeBSD.org (Warner Losh) Date: Sun Oct 12 06:58:15 2008 Subject: svn commit: r183773 - head/etc/etc.mips Message-ID: <200810120658.m9C6w3XK037535@svn.freebsd.org> Author: imp Date: Sun Oct 12 06:58:03 2008 New Revision: 183773 URL: http://svn.freebsd.org/changeset/base/183773 Log: Add entries for uart based serial ports. All the serial ports on mips so far are uart subclasses. Also, turn uart0 on by default. Modified: head/etc/etc.mips/ttys Modified: head/etc/etc.mips/ttys ============================================================================== --- head/etc/etc.mips/ttys Sun Oct 12 02:52:56 2008 (r183772) +++ head/etc/etc.mips/ttys Sun Oct 12 06:58:03 2008 (r183773) @@ -33,10 +33,10 @@ console none unknown off secure # Serial terminals # The 'dialup' keyword identifies dialin lines to login, fingerd etc. -ttyU0 "/usr/libexec/getty std.9600" dialup off secure -ttyU1 "/usr/libexec/getty std.9600" dialup off secure -ttyU2 "/usr/libexec/getty std.9600" dialup off secure -ttyU3 "/usr/libexec/getty std.9600" dialup off secure +ttyu0 "/usr/libexec/getty std.115200" dialup on secure +ttyu1 "/usr/libexec/getty std.115200" dialup off secure +ttyu2 "/usr/libexec/getty std.115200" dialup off secure +ttyu3 "/usr/libexec/getty std.115200" dialup off secure # Pseudo terminals ttyp0 none network ttyp1 none network From imp at bsdimp.com Sun Oct 12 07:16:06 2008 From: imp at bsdimp.com (M. Warner Losh) Date: Sun Oct 12 07:16:16 2008 Subject: svn commit: r183765 - head/sys/dev/mmc In-Reply-To: <200810111730.m9BHU2u1023174@svn.freebsd.org> References: <200810111730.m9BHU2u1023174@svn.freebsd.org> Message-ID: <20081012.011445.163262685.imp@bsdimp.com> In message: <200810111730.m9BHU2u1023174@svn.freebsd.org> Alexander Motin writes: : Author: mav : Date: Sat Oct 11 17:30:02 2008 : New Revision: 183765 : URL: http://svn.freebsd.org/changeset/base/183765 : : Log: : SELECT_CARD command with zero RCA deselects all cards and so has no reply. : : Modified: : head/sys/dev/mmc/mmc.c : : Modified: head/sys/dev/mmc/mmc.c : ============================================================================== : --- head/sys/dev/mmc/mmc.c Sat Oct 11 17:28:22 2008 (r183764) : +++ head/sys/dev/mmc/mmc.c Sat Oct 11 17:30:02 2008 (r183765) : @@ -526,7 +526,7 @@ static int : mmc_select_card(struct mmc_softc *sc, uint16_t rca) : { : return (mmc_wait_for_command(sc, MMC_SELECT_CARD, ((uint32_t)rca) << 16, : - MMC_RSP_R1B | MMC_CMD_AC, NULL, CMD_RETRIES)); : + (rca?MMC_RSP_R1B:MMC_RSP_NONE) | MMC_CMD_AC, NULL, CMD_RETRIES)); Tertiary operators have spaces around ? and : in style(9), and the rest of this file uses that style. Warner From imp at FreeBSD.org Sun Oct 12 07:24:31 2008 From: imp at FreeBSD.org (Warner Losh) Date: Sun Oct 12 07:24:42 2008 Subject: svn commit: r183774 - head/sys/dev/mmc Message-ID: <200810120724.m9C7OVD8038016@svn.freebsd.org> Author: imp Date: Sun Oct 12 07:24:31 2008 New Revision: 183774 URL: http://svn.freebsd.org/changeset/base/183774 Log: Print the cards natural size. Move nested tertiary operator expressions into their own function. Remove extra blank line. cache sd->disk in 'd' to make the code easier to read. Modified: head/sys/dev/mmc/mmcsd.c Modified: head/sys/dev/mmc/mmcsd.c ============================================================================== --- head/sys/dev/mmc/mmcsd.c Sun Oct 12 06:58:03 2008 (r183773) +++ head/sys/dev/mmc/mmcsd.c Sun Oct 12 07:24:31 2008 (r183774) @@ -93,6 +93,9 @@ static int mmcsd_close(struct disk *dp); static void mmcsd_strategy(struct bio *bp); static void mmcsd_task(void *arg); +static const char *mmcsd_card_name(device_t dev); +static int mmcsd_bus_bit_width(device_t dev); + #define MMCSD_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) #define MMCSD_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) #define MMCSD_LOCK_INIT(_sc) \ @@ -115,34 +118,46 @@ static int mmcsd_attach(device_t dev) { struct mmcsd_softc *sc; + struct disk *d; + intmax_t mb; + char unit; sc = device_get_softc(dev); sc->dev = dev; MMCSD_LOCK_INIT(sc); - sc->disk = disk_alloc(); - sc->disk->d_open = mmcsd_open; - sc->disk->d_close = mmcsd_close; - sc->disk->d_strategy = mmcsd_strategy; - // sc->disk->d_dump = mmcsd_dump; Need polling mmc layer - sc->disk->d_name = "mmcsd"; - sc->disk->d_drv1 = sc; - sc->disk->d_maxsize = MAXPHYS; /* Maybe ask bridge? */ - sc->disk->d_sectorsize = mmc_get_sector_size(dev); - sc->disk->d_mediasize = mmc_get_media_size(dev) * - mmc_get_sector_size(dev); - sc->disk->d_unit = device_get_unit(dev); - - device_printf(dev, "%juMB <%s Memory Card>%s at %s %dMHz/%dbit\n", - sc->disk->d_mediasize / 1048576, - (mmc_get_card_type(dev) == mode_mmc)?"MMC": - (mmc_get_high_cap(dev)?"SDHC":"SD"), - mmc_get_read_only(dev)?" (read-only)":"", - device_get_nameunit(device_get_parent(sc->dev)), - mmc_get_tran_speed(dev)/1000000, - (mmc_get_bus_width(dev) == bus_width_1)?1: - ((mmc_get_bus_width(dev) == bus_width_4)?4:8)); - disk_create(sc->disk, DISK_VERSION); + d = sc->disk = disk_alloc(); + d->d_open = mmcsd_open; + d->d_close = mmcsd_close; + d->d_strategy = mmcsd_strategy; + // d->d_dump = mmcsd_dump; Need polling mmc layer + d->d_name = "mmcsd"; + d->d_drv1 = sc; + d->d_maxsize = MAXPHYS; /* Maybe ask bridge? */ + d->d_sectorsize = mmc_get_sector_size(dev); + d->d_mediasize = mmc_get_media_size(dev) * d->d_sectorsize; + d->d_unit = device_get_unit(dev); + /* + * Display in most natural units. There's no cards < 1MB. + * The SD standard goes to 2GiB, but the data format supports + * up to 4GiB and some card makers push it up to this limit. + * The SDHC standard only goes to 32GiB (the data format in + * SDHC is good to 2TiB however, which isn't too ugly at + * 2048GiBm, so we note it in passing here and don't add the + * code to print TiB). + */ + mb = d->d_mediasize >> 20; /* 1MiB == 1 << 20 */ + unit = 'M'; + if (mb > 1024) { /* 1GiB = 1024 MiB */ + unit = 'G'; + mb /= 1024; + } + device_printf(dev, "%ju%cB <%s Memory Card>%s at %s %dMHz/%dbit\n", + mb, unit, mmcsd_card_name(dev), + mmc_get_read_only(dev) ? " (read-only)" : "", + device_get_nameunit(device_get_parent(dev)), + mmc_get_tran_speed(dev) / 1000000, mmcsd_bus_bit_width(dev)); + disk_create(d, DISK_VERSION); bioq_init(&sc->bio_queue); sc->running = 1; @@ -306,6 +321,26 @@ mmcsd_task(void *arg) kproc_exit(0); } +static const char * +mmcsd_card_name(device_t dev) +{ + if (mmc_get_card_type(dev) == mode_mmc) + return ("MMC"); + if (mmc_get_high_cap(dev)) + return ("SDHC"); + return ("SD"); +} + +static int +mmcsd_bus_bit_width(device_t dev) +{ + if (mmc_get_bus_width(dev) == bus_width_1) + return (1); + if (mmc_get_bus_width(dev) == bus_width_4) + return (4); + return (8); +} + static device_method_t mmcsd_methods[] = { DEVMETHOD(device_probe, mmcsd_probe), DEVMETHOD(device_attach, mmcsd_attach), @@ -320,5 +355,4 @@ static driver_t mmcsd_driver = { }; static devclass_t mmcsd_devclass; - DRIVER_MODULE(mmcsd, mmc, mmcsd_driver, mmcsd_devclass, 0, 0); From imp at FreeBSD.org Sun Oct 12 07:30:06 2008 From: imp at FreeBSD.org (Warner Losh) Date: Sun Oct 12 07:30:12 2008 Subject: svn commit: r183775 - head/sys/dev/mmc Message-ID: <200810120730.m9C7U61E038143@svn.freebsd.org> Author: imp Date: Sun Oct 12 07:30:05 2008 New Revision: 183775 URL: http://svn.freebsd.org/changeset/base/183775 Log: style(9): spaces around operators. Modified: head/sys/dev/mmc/mmc.c Modified: head/sys/dev/mmc/mmc.c ============================================================================== --- head/sys/dev/mmc/mmc.c Sun Oct 12 07:24:31 2008 (r183774) +++ head/sys/dev/mmc/mmc.c Sun Oct 12 07:30:05 2008 (r183775) @@ -219,8 +219,8 @@ mmc_acquire_bus(device_t busdev, device_ if (bootverbose) { device_printf(busdev, "setting bus width to %d bits\n", - (ivar->bus_width == bus_width_4)?4: - (ivar->bus_width == bus_width_8)?8:1); + (ivar->bus_width == bus_width_4) ? 4 : + (ivar->bus_width == bus_width_8) ? 8 : 1); } mmc_set_card_bus_width(sc, rca, ivar->bus_width); mmcbr_set_bus_width(busdev, ivar->bus_width); @@ -525,8 +525,11 @@ mmc_power_down(struct mmc_softc *sc) static int mmc_select_card(struct mmc_softc *sc, uint16_t rca) { - return (mmc_wait_for_command(sc, MMC_SELECT_CARD, ((uint32_t)rca) << 16, - (rca?MMC_RSP_R1B:MMC_RSP_NONE) | MMC_CMD_AC, NULL, CMD_RETRIES)); + int flags; + + flags = (rca ? MMC_RSP_R1B : MMC_RSP_NONE) | MMC_CMD_AC; + return (mmc_wait_for_command(sc, MMC_SELECT_CARD, (uint32_t)rca << 16, + flags, NULL, CMD_RETRIES)); } static int @@ -1133,7 +1136,7 @@ mmc_go_discovery(struct mmc_softc *sc) mmcbr_set_bus_mode(dev, pushpull); mmc_idle_cards(sc); err = mmc_send_if_cond(sc, 1); - if (mmc_send_app_op_cond(sc, err?0:MMC_OCR_CCS, &ocr) != + if (mmc_send_app_op_cond(sc, err ? 0 : MMC_OCR_CCS, &ocr) != MMC_ERR_NONE) { /* * Failed, try MMC @@ -1163,7 +1166,7 @@ mmc_go_discovery(struct mmc_softc *sc) if (mmcbr_get_mode(dev) == mode_sd) { err = mmc_send_if_cond(sc, 1); mmc_send_app_op_cond(sc, - (err?0:MMC_OCR_CCS)|mmcbr_get_ocr(dev), NULL); + (err ? 0 : MMC_OCR_CCS) | mmcbr_get_ocr(dev), NULL); } else mmc_send_op_cond(sc, mmcbr_get_ocr(dev), NULL); mmc_discover_cards(sc); @@ -1213,9 +1216,10 @@ mmc_calculate_clock(struct mmc_softc *sc if (max_timing == bus_timing_hs) max_dtr = max_hs_dtr; if (bootverbose) { - device_printf(sc->dev, "setting transfer rate to %d.%03dMHz%s\n", + device_printf(sc->dev, + "setting transfer rate to %d.%03dMHz%s\n", max_dtr / 1000000, (max_dtr / 1000) % 1000, - (max_timing == bus_timing_hs)?" with high speed timing":""); + max_timing == bus_timing_hs ? " (high speed timing)" : ""); } mmcbr_set_timing(sc->dev, max_timing); mmcbr_set_clock(sc->dev, max_dtr); From simon at FreeBSD.org Sun Oct 12 08:22:54 2008 From: simon at FreeBSD.org (Simon L. Nielsen) Date: Sun Oct 12 08:23:04 2008 Subject: svn commit: r183776 - head/release/doc/share/misc Message-ID: <200810120822.m9C8MrcX039064@svn.freebsd.org> Author: simon Date: Sun Oct 12 08:22:53 2008 New Revision: 183776 URL: http://svn.freebsd.org/changeset/base/183776 Log: ncr(4) is not supported on sparc64. See also: r183762 Modified: head/release/doc/share/misc/dev.archlist.txt Modified: head/release/doc/share/misc/dev.archlist.txt ============================================================================== --- head/release/doc/share/misc/dev.archlist.txt Sun Oct 12 07:30:05 2008 (r183775) +++ head/release/doc/share/misc/dev.archlist.txt Sun Oct 12 08:22:53 2008 (r183776) @@ -88,7 +88,7 @@ mly i386,ia64,amd64 msk i386,amd64 mxge i386,amd64 my i386,pc98 -ncr i386,pc98,sparc64,amd64 +ncr i386,pc98,amd64 ncv i386,pc98 nfe i386,amd64 ng_bt3c i386,pc98,amd64 From mav at FreeBSD.org Sun Oct 12 19:19:27 2008 From: mav at FreeBSD.org (Alexander Motin) Date: Sun Oct 12 19:19:33 2008 Subject: svn commit: r183805 - head/sys/dev/mmc Message-ID: <200810121919.m9CJJQ2t053333@svn.freebsd.org> Author: mav Date: Sun Oct 12 19:19:26 2008 New Revision: 183805 URL: http://svn.freebsd.org/changeset/base/183805 Log: Use GB suffix only from 10GB instead of 1GB. There are lot of cards with uneven sizes and too strong rounding will lead to very significant rounding errors. Reviewed by: imp@ Modified: head/sys/dev/mmc/mmcsd.c Modified: head/sys/dev/mmc/mmcsd.c ============================================================================== --- head/sys/dev/mmc/mmcsd.c Sun Oct 12 18:49:07 2008 (r183804) +++ head/sys/dev/mmc/mmcsd.c Sun Oct 12 19:19:26 2008 (r183805) @@ -148,7 +148,7 @@ mmcsd_attach(device_t dev) */ mb = d->d_mediasize >> 20; /* 1MiB == 1 << 20 */ unit = 'M'; - if (mb > 1024) { /* 1GiB = 1024 MiB */ + if (mb >= 10240) { /* 1GiB = 1024 MiB */ unit = 'G'; mb /= 1024; } From rwatson at FreeBSD.org Sun Oct 12 19:23:02 2008 From: rwatson at FreeBSD.org (Robert Watson) Date: Sun Oct 12 19:23:13 2008 Subject: svn commit: r183806 - head/sys/fs/portalfs Message-ID: <200810121923.m9CJN2F0053444@svn.freebsd.org> Author: rwatson Date: Sun Oct 12 19:23:02 2008 New Revision: 183806 URL: http://svn.freebsd.org/changeset/base/183806 Log: The locking in portalfs's socket connect code is no less correct than identical code in connect(2), so remove XXX that it might be incorrect. MFC after: 3 days Modified: head/sys/fs/portalfs/portal_vnops.c Modified: head/sys/fs/portalfs/portal_vnops.c ============================================================================== --- head/sys/fs/portalfs/portal_vnops.c Sun Oct 12 19:19:26 2008 (r183805) +++ head/sys/fs/portalfs/portal_vnops.c Sun Oct 12 19:23:02 2008 (r183806) @@ -279,7 +279,6 @@ portal_open(ap) * will happen if the server dies. Sleep for 5 second intervals * and keep polling the reference count. XXX. */ - /* XXXRW: Locking? */ SOCK_LOCK(so); while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) { if (fmp->pm_server->f_count == 1) { From rwatson at FreeBSD.org Sun Oct 12 20:01:33 2008 From: rwatson at FreeBSD.org (Robert Watson) Date: Sun Oct 12 20:01:39 2008 Subject: svn commit: r183807 - head/sys/netinet6 Message-ID: <200810122001.m9CK1WAj054137@svn.freebsd.org> Author: rwatson Date: Sun Oct 12 20:01:32 2008 New Revision: 183807 URL: http://svn.freebsd.org/changeset/base/183807 Log: When disconnecting a UDPv6 socket, acquire the socket lock around the changing of the so_state field, as is done in UDPv4. Remove XXX locking comment. MFC after: 3 days Modified: head/sys/netinet6/udp6_usrreq.c Modified: head/sys/netinet6/udp6_usrreq.c ============================================================================== --- head/sys/netinet6/udp6_usrreq.c Sun Oct 12 19:23:02 2008 (r183806) +++ head/sys/netinet6/udp6_usrreq.c Sun Oct 12 20:01:32 2008 (r183807) @@ -935,8 +935,9 @@ udp6_disconnect(struct socket *so) in6_pcbdisconnect(inp); inp->in6p_laddr = in6addr_any; - /* XXXRW: so_state locking? */ + SOCK_LOCK(so); so->so_state &= ~SS_ISCONNECTED; /* XXX */ + SOCK_UNLOCK(so); out: INP_WUNLOCK(inp); INP_INFO_WUNLOCK(&V_udbinfo); From rwatson at FreeBSD.org Sun Oct 12 20:03:18 2008 From: rwatson at FreeBSD.org (Robert Watson) Date: Sun Oct 12 20:03:24 2008 Subject: svn commit: r183808 - head/sys/kern Message-ID: <200810122003.m9CK3HXN054209@svn.freebsd.org> Author: rwatson Date: Sun Oct 12 20:03:17 2008 New Revision: 183808 URL: http://svn.freebsd.org/changeset/base/183808 Log: Downgrade XXX to a Note for fgetsock() and fputsock(). MFC after: 3 days Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Sun Oct 12 20:01:32 2008 (r183807) +++ head/sys/kern/kern_descrip.c Sun Oct 12 20:03:17 2008 (r183808) @@ -2150,7 +2150,7 @@ fgetvp_write(struct thread *td, int fd, * We bump the ref count on the returned socket. XXX Also obtain the SX lock * in the future. * - * XXXRW: fgetsock() and fputsock() are deprecated, as consumers should rely + * Note: fgetsock() and fputsock() are deprecated, as consumers should rely * on their file descriptor reference to prevent the socket from being free'd * during use. */ @@ -2183,7 +2183,7 @@ fgetsock(struct thread *td, int fd, stru * Drop the reference count on the socket and XXX release the SX lock in the * future. The last reference closes the socket. * - * XXXRW: fputsock() is deprecated, see comment for fgetsock(). + * Note: fputsock() is deprecated, see comment for fgetsock(). */ void fputsock(struct socket *so) From rwatson at FreeBSD.org Sun Oct 12 20:06:59 2008 From: rwatson at FreeBSD.org (Robert Watson) Date: Sun Oct 12 20:07:06 2008 Subject: svn commit: r183809 - head/sys/nfsserver Message-ID: <200810122006.m9CK6x3n054298@svn.freebsd.org> Author: rwatson Date: Sun Oct 12 20:06:59 2008 New Revision: 183809 URL: http://svn.freebsd.org/changeset/base/183809 Log: Turn XXX's for unlocked writes of NFS server statistics to simple notes, as we consider it a feature to exchange performance for consistency. MFC after: 3 days Modified: head/sys/nfsserver/nfs_serv.c Modified: head/sys/nfsserver/nfs_serv.c ============================================================================== --- head/sys/nfsserver/nfs_serv.c Sun Oct 12 20:03:17 2008 (r183808) +++ head/sys/nfsserver/nfs_serv.c Sun Oct 12 20:06:59 2008 (r183809) @@ -1174,7 +1174,7 @@ nfsrv_write(struct nfsrv_descript *nfsd, uiop->uio_td = NULL; uiop->uio_offset = off; error = VOP_WRITE(vp, uiop, ioflags, cred); - /* XXXRW: unlocked write. */ + /* Unlocked write. */ nfsrvstats.srvvop_writes++; FREE((caddr_t)iv, M_TEMP); } @@ -1488,7 +1488,7 @@ loop1: } if (!error) { error = VOP_WRITE(vp, uiop, ioflags, cred); - /* XXXRW: unlocked write. */ + /* Unlocked write. */ nfsrvstats.srvvop_writes++; vn_finished_write(mntp); } From mav at FreeBSD.org Sun Oct 12 21:42:22 2008 From: mav at FreeBSD.org (Alexander Motin) Date: Sun Oct 12 21:42:35 2008 Subject: svn commit: r183810 - head/sys/dev/sound/pci/hda Message-ID: <200810122142.m9CLgLaj056258@svn.freebsd.org> Author: mav Date: Sun Oct 12 21:42:21 2008 New Revision: 183810 URL: http://svn.freebsd.org/changeset/base/183810 Log: Fix bug in a second call of the channel allocation function. This should fix crash on systems where two audio codecs connected to the same HDA bus. Modified: head/sys/dev/sound/pci/hda/hdac.c Modified: head/sys/dev/sound/pci/hda/hdac.c ============================================================================== --- head/sys/dev/sound/pci/hda/hdac.c Sun Oct 12 20:06:59 2008 (r183809) +++ head/sys/dev/sound/pci/hda/hdac.c Sun Oct 12 21:42:21 2008 (r183810) @@ -4945,7 +4945,7 @@ hdac_audio_bind_as(struct hdac_devinfo * } } else { sc->chans = (struct hdac_chan *)realloc(sc->chans, - sizeof(struct hdac_chan) * cnt, + sizeof(struct hdac_chan) * (sc->num_chans + cnt), M_HDAC, M_ZERO | M_NOWAIT); if (sc->chans == NULL) { sc->num_chans = 0; @@ -4963,7 +4963,6 @@ hdac_audio_bind_as(struct hdac_devinfo * } /* Assign associations in order of their numbers, */ - free = 0; for (j = 0; j < devinfo->function.audio.ascnt; j++) { if (as[j].enable == 0) continue; From mav at FreeBSD.org Sun Oct 12 21:46:11 2008 From: mav at FreeBSD.org (Alexander Motin) Date: Sun Oct 12 21:46:22 2008 Subject: svn commit: r183811 - head/sys/dev/sound/pci/hda Message-ID: <200810122146.m9CLkBjW056367@svn.freebsd.org> Author: mav Date: Sun Oct 12 21:46:11 2008 New Revision: 183811 URL: http://svn.freebsd.org/changeset/base/183811 Log: Bump driver revision after the previous commit. Modified: head/sys/dev/sound/pci/hda/hdac.c Modified: head/sys/dev/sound/pci/hda/hdac.c ============================================================================== --- head/sys/dev/sound/pci/hda/hdac.c Sun Oct 12 21:42:21 2008 (r183810) +++ head/sys/dev/sound/pci/hda/hdac.c Sun Oct 12 21:46:11 2008 (r183811) @@ -83,7 +83,7 @@ #include "mixer_if.h" -#define HDA_DRV_TEST_REV "20080916_0112" +#define HDA_DRV_TEST_REV "20081013_0113" SND_DECLARE_FILE("$FreeBSD$"); From yongari at FreeBSD.org Mon Oct 13 01:11:29 2008 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Mon Oct 13 01:11:34 2008 Subject: svn commit: r183814 - head/sys/dev/jme Message-ID: <200810130111.m9D1BScB059950@svn.freebsd.org> Author: yongari Date: Mon Oct 13 01:11:28 2008 New Revision: 183814 URL: http://svn.freebsd.org/changeset/base/183814 Log: Read PCI device id instead of PCI revision id. Also checks the read device id is JMC260 family. Previously it just verified the deivce is JMC260 Rev A0. This will make it easy for newer JMC2xx support. Pointed out by: bouyer at NetBSD Modified: head/sys/dev/jme/if_jme.c head/sys/dev/jme/if_jmereg.h Modified: head/sys/dev/jme/if_jme.c ============================================================================== --- head/sys/dev/jme/if_jme.c Sun Oct 12 23:47:06 2008 (r183813) +++ head/sys/dev/jme/if_jme.c Mon Oct 13 01:11:28 2008 (r183814) @@ -624,8 +624,8 @@ jme_attach(device_t dev) goto fail; } - sc->jme_rev = pci_get_revid(dev); - if (sc->jme_rev == DEVICEID_JMC260) { + sc->jme_rev = pci_get_device(dev); + if ((sc->jme_rev & DEVICEID_JMC2XX_MASK) == DEVICEID_JMC260) { sc->jme_flags |= JME_FLAG_FASTETH; sc->jme_flags |= JME_FLAG_NOJUMBO; } Modified: head/sys/dev/jme/if_jmereg.h ============================================================================== --- head/sys/dev/jme/if_jmereg.h Sun Oct 12 23:47:06 2008 (r183813) +++ head/sys/dev/jme/if_jmereg.h Mon Oct 13 01:11:28 2008 (r183814) @@ -48,6 +48,8 @@ #define DEVICEID_JMC260 0x0260 #define DEVICEREVID_JMC260_A0 0x00 +#define DEVICEID_JMC2XX_MASK 0x0FF0 + /* JMC250 PCI configuration register. */ #define JME_PCI_BAR0 0x10 /* 16KB memory window. */ From bms at FreeBSD.org Mon Oct 13 06:07:59 2008 From: bms at FreeBSD.org (Bruce M Simpson) Date: Mon Oct 13 06:08:11 2008 Subject: svn commit: r183815 - head/sys/conf Message-ID: <200810130607.m9D67wNU065197@svn.freebsd.org> Author: bms Date: Mon Oct 13 06:07:58 2008 New Revision: 183815 URL: http://svn.freebsd.org/changeset/base/183815 Log: Fix the CFE ldscript after the cutover to tradmips. Diff minimization against ldscript.mips. Note: CFE will not load PT_DYNAMIC segments, therefore the dynamic sections have been placed in a PT_LOAD segment for now. This is not too efficient in terms of memory use, they should probably get placed in the text segment. Modified: head/sys/conf/ldscript.mips.cfe Modified: head/sys/conf/ldscript.mips.cfe ============================================================================== --- head/sys/conf/ldscript.mips.cfe Mon Oct 13 01:11:28 2008 (r183814) +++ head/sys/conf/ldscript.mips.cfe Mon Oct 13 06:07:58 2008 (r183815) @@ -1,9 +1,46 @@ +/*- + * Copyright (c) 2001, 2004, 2008, Juniper Networks, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Juniper Networks, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JUNIPER NETWORKS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JUNIPER NETWORKS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * JNPR: ldscript.mips,v 1.3 2006/10/11 06:12:04 + * $FreeBSD$ + */ + /* - * This linker script is needed to build a kernel for use by Broadcom CFE. + * This linker script is needed to build a kernel for use by Broadcom CFE + * when loaded over TFTP; its ELF loader does not support backwards seek + * on network I/O streams. + * Furthermore, CFE will only load PT_LOAD segments, therefore the dynamic + * sections must be placed in their own segment. */ -/* $FreeBSD$ */ -OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", "elf32-tradlittlemips") +OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips", + "elf32-tradlittlemips") + OUTPUT_ARCH(mips) ENTRY(_start) SEARCH_DIR(/usr/lib); @@ -11,23 +48,22 @@ SEARCH_DIR(/usr/lib); __DYNAMIC = 0; PROVIDE (_DYNAMIC = 0); */ -DYNAMIC_LINK = 0; /* XXX */ + +PHDRS +{ + headers PT_PHDR FILEHDR PHDRS ; + interp PT_INTERP ; + text PT_LOAD ; + dynamic PT_LOAD ; + data PT_LOAD ; +} + SECTIONS { /* Read-only sections, merged into text segment: */ - . = 0x80001000; - .text : - { - *(.trap) - *(.text) - *(.text.*) - *(.stub) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - *(.gnu.linkonce.t.*) - } - .interp : { *(.interp) } - .hash : { *(.hash) } + . = 0x80100000 ; + .interp : { *(.interp) } :interp + .hash : { *(.hash) } :text .dynsym : { *(.dynsym) } .dynstr : { *(.dynstr) } .gnu.version : { *(.gnu.version) } @@ -141,12 +177,20 @@ SECTIONS } .rel.plt : { *(.rel.plt) } .rela.plt : { *(.rela.plt) } - .init : { KEEP (*(.init)) - } - + } :text =0x1000000 + .text : + { + *(.trap) + *(.text) + *(.text.*) + *(.stub) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t.*) + } =0x1000000 .fini : { KEEP (*(.fini)) @@ -166,7 +210,7 @@ SECTIONS *(.data.*) *(.gnu.linkonce.d.*) SORT(CONSTRUCTORS) - } + } :data .data1 : { *(.data1) } .eh_frame : { KEEP (*(.eh_frame)) } .gcc_except_table : { *(.gcc_except_table) } @@ -200,7 +244,7 @@ SECTIONS .plt : { *(.plt) } _gp = ALIGN(16) + 0x7ff0; .got : { *(.got.plt) *(.got) } - .dynamic : { *(.dynamic) } + .dynamic : { *(.dynamic) } :dynamic /* We want the small data sections together, so single-instruction offsets can access them all, and initialized data all before uninitialized, so we can shorten the on-disk segment size. */ From bms at FreeBSD.org Mon Oct 13 06:25:29 2008 From: bms at FreeBSD.org (Bruce M Simpson) Date: Mon Oct 13 06:25:35 2008 Subject: svn commit: r183816 - head/sys/mips/conf Message-ID: <200810130625.m9D6PTOW065537@svn.freebsd.org> Author: bms Date: Mon Oct 13 06:25:28 2008 New Revision: 183816 URL: http://svn.freebsd.org/changeset/base/183816 Log: Point this config at the required linker script. Modified: head/sys/mips/conf/SENTRY5 Modified: head/sys/mips/conf/SENTRY5 ============================================================================== --- head/sys/mips/conf/SENTRY5 Mon Oct 13 06:07:58 2008 (r183815) +++ head/sys/mips/conf/SENTRY5 Mon Oct 13 06:25:28 2008 (r183816) @@ -47,6 +47,8 @@ options ALT_BREAK_TO_DEBUGGER # XXX can we conditionalize the linker stuff on options CFE? options KERNVIRTADDR=0x80001000 +makeoptions LDSCRIPT_NAME= ldscript.mips.cfe + #makeoptions ARCH_FLAGS=-march=mips32 makeoptions MIPS_LITTLE_ENDIAN=defined makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols From des at FreeBSD.org Mon Oct 13 12:28:33 2008 From: des at FreeBSD.org (Dag-Erling Smorgrav) Date: Mon Oct 13 12:28:40 2008 Subject: svn commit: r183817 - head/sys/dev/puc Message-ID: <200810131228.m9DCSXql076150@svn.freebsd.org> Author: des Date: Mon Oct 13 12:28:33 2008 New Revision: 183817 URL: http://svn.freebsd.org/changeset/base/183817 Log: Revert r179409; it breaks all OX16PCI954-based cards except the SIIG 4. MFC after: 3 days Modified: head/sys/dev/puc/pucdata.c Modified: head/sys/dev/puc/pucdata.c ============================================================================== --- head/sys/dev/puc/pucdata.c Mon Oct 13 06:25:28 2008 (r183816) +++ head/sys/dev/puc/pucdata.c Mon Oct 13 12:28:33 2008 (r183817) @@ -603,14 +603,14 @@ const struct puc_cfg puc_pci_devices[] = }, { 0x1415, 0x9501, 0xffff, 0, - "Oxford Semiconductor OX16PCI954 UARTs 4-port type 1", - DEFAULT_RCLK * 10, + "Oxford Semiconductor OX16PCI954 UARTs", + DEFAULT_RCLK, PUC_PORT_4S, 0x10, 0, 8, }, { 0x1415, 0x950a, 0xffff, 0, - "Oxford Semiconductor OX16PCI954 UARTs 4-port type 2", - DEFAULT_RCLK * 10, + "Oxford Semiconductor OX16PCI954 UARTs", + DEFAULT_RCLK, PUC_PORT_4S, 0x10, 0, 8, }, From kib at FreeBSD.org Mon Oct 13 13:56:23 2008 From: kib at FreeBSD.org (Konstantin Belousov) Date: Mon Oct 13 13:56:35 2008 Subject: svn commit: r183820 - head/sbin/fsck_ffs Message-ID: <200810131356.m9DDuNhA077736@svn.freebsd.org> Author: kib Date: Mon Oct 13 13:56:23 2008 New Revision: 183820 URL: http://svn.freebsd.org/changeset/base/183820 Log: check_maps() in /usr/src/sbin/fsck_ffs/pass5.c seems to be limited to file systems less than 1 TB, due to using 32-bits integers for file system block numbers. This also causes incorrect error reporting for foreground fsck. Convert it to use ufs2_daddr_t for block numbers. PR: kern/127951 Submitted by: tegge MFC after: 1 week Modified: head/sbin/fsck_ffs/pass5.c Modified: head/sbin/fsck_ffs/pass5.c ============================================================================== --- head/sbin/fsck_ffs/pass5.c Mon Oct 13 13:00:21 2008 (r183819) +++ head/sbin/fsck_ffs/pass5.c Mon Oct 13 13:56:23 2008 (r183820) @@ -48,7 +48,7 @@ __FBSDID("$FreeBSD$"); #include "fsck.h" -static void check_maps(u_char *, u_char *, int, int, const char *, int *, int, int); +static void check_maps(u_char *, u_char *, int, ufs2_daddr_t, const char *, int *, int, int); void pass5(void) @@ -321,13 +321,17 @@ pass5(void) } if (excessdirs > 0) check_maps(cg_inosused(newcg), cg_inosused(cg), - inomapsize, cg->cg_cgx * fs->fs_ipg, "DIR", + inomapsize, + cg->cg_cgx * (ufs2_daddr_t) fs->fs_ipg, + "DIR", freedirs, 0, excessdirs); check_maps(cg_inosused(newcg), cg_inosused(cg), - inomapsize, cg->cg_cgx * fs->fs_ipg, "FILE", + inomapsize, + cg->cg_cgx * (ufs2_daddr_t) fs->fs_ipg, "FILE", freefiles, excessdirs, fs->fs_ipg); check_maps(cg_blksfree(cg), cg_blksfree(newcg), - blkmapsize, cg->cg_cgx * fs->fs_fpg, "FRAG", + blkmapsize, + cg->cg_cgx * (ufs2_daddr_t) fs->fs_fpg, "FRAG", freeblks, 0, fs->fs_fpg); } if (cursnapshot == 0 && @@ -407,7 +411,7 @@ check_maps( u_char *map1, /* map of claimed allocations */ u_char *map2, /* map of determined allocations */ int mapsize, /* size of above two maps */ - int startvalue, /* resource value for first element in map */ + ufs2_daddr_t startvalue, /* resource value for first element in map */ const char *name, /* name of resource found in maps */ int *opcode, /* sysctl opcode to free resource */ int skip, /* number of entries to skip before starting to free */ @@ -415,8 +419,8 @@ check_maps( { # define BUFSIZE 16 char buf[BUFSIZE]; - long i, j, k, l, m, n, size; - int astart, aend, ustart, uend; + long i, j, k, l, m, size; + ufs2_daddr_t n, astart, aend, ustart, uend; void (*msg)(const char *fmt, ...); if (bkgrdflag) @@ -443,10 +447,12 @@ check_maps( continue; } if (astart == aend) - (*msg)("ALLOCATED %s %d MARKED FREE\n", + (*msg)("ALLOCATED %s %" PRId64 + " MARKED FREE\n", name, astart); else - (*msg)("%s %sS %d-%d MARKED FREE\n", + (*msg)("%s %sS %" PRId64 "-%" PRId64 + " MARKED FREE\n", "ALLOCATED", name, astart, aend); astart = aend = n; } else { @@ -472,10 +478,12 @@ check_maps( if (size > limit) size = limit; if (debug && size == 1) - pwarn("%s %s %d MARKED USED\n", + pwarn("%s %s %" PRId64 + " MARKED USED\n", "UNALLOCATED", name, ustart); else if (debug) - pwarn("%s %sS %d-%ld MARKED USED\n", + pwarn("%s %sS %" PRId64 "-%" PRId64 + " MARKED USED\n", "UNALLOCATED", name, ustart, ustart + size - 1); if (bkgrdflag != 0) { @@ -497,9 +505,11 @@ check_maps( } if (astart != -1) { if (astart == aend) - (*msg)("ALLOCATED %s %d MARKED FREE\n", name, astart); + (*msg)("ALLOCATED %s %" PRId64 + " MARKED FREE\n", name, astart); else - (*msg)("ALLOCATED %sS %d-%d MARKED FREE\n", + (*msg)("ALLOCATED %sS %" PRId64 "-%" PRId64 + " MARKED FREE\n", name, astart, aend); } if (ustart != -1) { @@ -514,10 +524,12 @@ check_maps( size = limit; if (debug) { if (size == 1) - pwarn("UNALLOCATED %s %d MARKED USED\n", + pwarn("UNALLOCATED %s %" PRId64 + " MARKED USED\n", name, ustart); else - pwarn("UNALLOCATED %sS %d-%ld MARKED USED\n", + pwarn("UNALLOCATED %sS %" PRId64 "-%" PRId64 + " MARKED USED\n", name, ustart, ustart + size - 1); } if (bkgrdflag != 0) { From kib at FreeBSD.org Mon Oct 13 14:01:06 2008 From: kib at FreeBSD.org (Konstantin Belousov) Date: Mon Oct 13 14:01:17 2008 Subject: svn commit: r183821 - head/sbin/fsck_ffs Message-ID: <200810131401.m9DE16LW077877@svn.freebsd.org> Author: kib Date: Mon Oct 13 14:01:05 2008 New Revision: 183821 URL: http://svn.freebsd.org/changeset/base/183821 Log: Background fsck applies twice some summary totals changes. The next background fsck on the same file system might then print negative numbers for reclaimed directories/files/fragments. Address the issue in a limited degree, by using old summary data for cg when bgfsck is performed. Submitted by: tegge MFC after: 1 week Modified: head/sbin/fsck_ffs/pass5.c Modified: head/sbin/fsck_ffs/pass5.c ============================================================================== --- head/sbin/fsck_ffs/pass5.c Mon Oct 13 13:56:23 2008 (r183820) +++ head/sbin/fsck_ffs/pass5.c Mon Oct 13 14:01:05 2008 (r183821) @@ -291,10 +291,17 @@ pass5(void) sump[run]++; } } - cstotal.cs_nffree += newcg->cg_cs.cs_nffree; - cstotal.cs_nbfree += newcg->cg_cs.cs_nbfree; - cstotal.cs_nifree += newcg->cg_cs.cs_nifree; - cstotal.cs_ndir += newcg->cg_cs.cs_ndir; + if (bkgrdflag != 0) { + cstotal.cs_nffree += cg->cg_cs.cs_nffree; + cstotal.cs_nbfree += cg->cg_cs.cs_nbfree; + cstotal.cs_nifree += cg->cg_cs.cs_nifree; + cstotal.cs_ndir += cg->cg_cs.cs_ndir; + } else { + cstotal.cs_nffree += newcg->cg_cs.cs_nffree; + cstotal.cs_nbfree += newcg->cg_cs.cs_nbfree; + cstotal.cs_nifree += newcg->cg_cs.cs_nifree; + cstotal.cs_ndir += newcg->cg_cs.cs_ndir; + } cs = &fs->fs_cs(fs, c); if (cursnapshot == 0 && memcmp(&newcg->cg_cs, cs, sizeof *cs) != 0 && From kib at FreeBSD.org Mon Oct 13 14:05:02 2008 From: kib at FreeBSD.org (Konstantin Belousov) Date: Mon Oct 13 14:05:13 2008 Subject: svn commit: r183822 - head/sys/ufs/ffs Message-ID: <200810131405.m9DE51Zq077977@svn.freebsd.org> Author: kib Date: Mon Oct 13 14:05:01 2008 New Revision: 183822 URL: http://svn.freebsd.org/changeset/base/183822 Log: Sync up summary information for cylinder groups while data is already in memory during snapshot creation. This improves the results of the background fsck. Submitted by: tegge MFC after: 1 week Modified: head/sys/ufs/ffs/ffs_snapshot.c Modified: head/sys/ufs/ffs/ffs_snapshot.c ============================================================================== --- head/sys/ufs/ffs/ffs_snapshot.c Mon Oct 13 14:01:05 2008 (r183821) +++ head/sys/ufs/ffs/ffs_snapshot.c Mon Oct 13 14:05:01 2008 (r183822) @@ -864,6 +864,13 @@ cgaccount(cg, vp, nbp, passno) } UFS_LOCK(ip->i_ump); ACTIVESET(fs, cg); + /* + * Recomputation of summary information might not have been performed + * at mount time. Sync up summary information for current cylinder + * group while data is in memory to ensure that result of background + * fsck is slightly more consistent. + */ + fs->fs_cs(fs, cg) = cgp->cg_cs; UFS_UNLOCK(ip->i_ump); bcopy(bp->b_data, nbp->b_data, fs->fs_cgsize); if (fs->fs_cgsize < fs->fs_bsize) From nwhitehorn at FreeBSD.org Mon Oct 13 17:14:30 2008 From: nwhitehorn at FreeBSD.org (Nathan Whitehorn) Date: Mon Oct 13 17:14:36 2008 Subject: svn commit: r183825 - head/sys/boot/ofw/libofw Message-ID: <200810131714.m9DHET4q081375@svn.freebsd.org> Author: nwhitehorn Date: Mon Oct 13 17:14:29 2008 New Revision: 183825 URL: http://svn.freebsd.org/changeset/base/183825 Log: Don't close OF disk devices on PowerPC. This fixes loader when booting from disk on my Blue & White G3 system. Modified: head/sys/boot/ofw/libofw/ofw_disk.c Modified: head/sys/boot/ofw/libofw/ofw_disk.c ============================================================================== --- head/sys/boot/ofw/libofw/ofw_disk.c Mon Oct 13 16:46:24 2008 (r183824) +++ head/sys/boot/ofw/libofw/ofw_disk.c Mon Oct 13 17:14:29 2008 (r183825) @@ -155,7 +155,9 @@ ofwd_close(struct open_file *f) if (odp->count == 0) { SLIST_REMOVE(&opened_devs, odp, opened_dev, link); + #if !defined(__powerpc__) OF_close(odp->handle); + #endif free(odp); } break; From nwhitehorn at FreeBSD.org Mon Oct 13 17:33:56 2008 From: nwhitehorn at FreeBSD.org (Nathan Whitehorn) Date: Mon Oct 13 17:34:19 2008 Subject: svn commit: r183827 - head/sys/dev/bm Message-ID: <200810131733.m9DHXtUc081804@svn.freebsd.org> Author: nwhitehorn Date: Mon Oct 13 17:33:55 2008 New Revision: 183827 URL: http://svn.freebsd.org/changeset/base/183827 Log: Change the way we enable the BMAC cell in macio. Instead of calling the macio's enable-enet word, which apparently does nothing on some machines, open an OF instance of the ethernet controller. This fixes cold booting from disk on my Blue & White G3. MFC after: 3 days Modified: head/sys/dev/bm/if_bm.c Modified: head/sys/dev/bm/if_bm.c ============================================================================== --- head/sys/dev/bm/if_bm.c Mon Oct 13 17:33:44 2008 (r183826) +++ head/sys/dev/bm/if_bm.c Mon Oct 13 17:33:55 2008 (r183827) @@ -1119,21 +1119,25 @@ bm_chip_setup(struct bm_softc *sc) { uint16_t reg; uint16_t *eaddr_sect; - char hrow_path[128]; - ihandle_t hrow_ih; + char path[128]; + ihandle_t bmac_ih; eaddr_sect = (uint16_t *)(sc->sc_enaddr); - /* Enable BMAC cell */ - OF_package_to_path(OF_parent(ofw_bus_get_node(sc->sc_dev)), - hrow_path, sizeof(hrow_path)); - hrow_ih = OF_open(hrow_path); - if (hrow_ih == -1) { + /* + * Enable BMAC cell by opening and closing its OF node. This enables + * the cell in macio as a side effect. We should probably directly + * twiddle the FCR bits, but we lack a good interface for this at the + * present time. + */ + + OF_package_to_path(ofw_bus_get_node(sc->sc_dev), path, sizeof(path)); + bmac_ih = OF_open(path); + if (bmac_ih == -1) { device_printf(sc->sc_dev, "Enabling BMAC cell failed! Hoping it's already active.\n"); } else { - OF_call_method("enable-enet", hrow_ih, 0, 0); - OF_close(hrow_ih); + OF_close(bmac_ih); } /* Reset chip */ From rnoland at FreeBSD.org Mon Oct 13 17:38:05 2008 From: rnoland at FreeBSD.org (Robert Noland) Date: Mon Oct 13 17:38:16 2008 Subject: svn commit: r183828 - head/sys/dev/drm Message-ID: <200810131738.m9DHc47A081913@svn.freebsd.org> Author: rnoland Date: Mon Oct 13 17:38:04 2008 New Revision: 183828 URL: http://svn.freebsd.org/changeset/base/183828 Log: Add support for Radeon rs740 (HD 2100) Approved by: jhb (mentor) Obtained from: drm git master Modified: head/sys/dev/drm/drm_pciids.h head/sys/dev/drm/radeon_cp.c head/sys/dev/drm/radeon_drv.h Modified: head/sys/dev/drm/drm_pciids.h ============================================================================== --- head/sys/dev/drm/drm_pciids.h Mon Oct 13 17:33:55 2008 (r183827) +++ head/sys/dev/drm/drm_pciids.h Mon Oct 13 17:38:04 2008 (r183828) @@ -242,6 +242,10 @@ {0x1002, 0x7835, CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Radeon RS350 Mobility IGP"}, \ {0x1002, 0x791e, CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS690 X1250 IGP"}, \ {0x1002, 0x791f, CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS690 X1270 IGP"}, \ + {0x1002, 0x796c, CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS740 HD2100 IGP"}, \ + {0x1002, 0x796d, CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS740 HD2100 IGP"}, \ + {0x1002, 0x796e, CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS740 HD2100 IGP"}, \ + {0x1002, 0x796f, CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS740 HD2100 IGP"}, \ {0, 0, 0, NULL} #define r128_PCI_IDS \ Modified: head/sys/dev/drm/radeon_cp.c ============================================================================== --- head/sys/dev/drm/radeon_cp.c Mon Oct 13 17:33:55 2008 (r183827) +++ head/sys/dev/drm/radeon_cp.c Mon Oct 13 17:38:04 2008 (r183828) @@ -73,7 +73,8 @@ static u32 RS690_READ_MCIND(drm_radeon_p static u32 IGP_READ_MCIND(drm_radeon_private_t *dev_priv, int addr) { - if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) + if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740)) return RS690_READ_MCIND(dev_priv, addr); else return RS480_READ_MCIND(dev_priv, addr); @@ -84,7 +85,8 @@ u32 radeon_read_fb_location(drm_radeon_p if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515) return R500_READ_MCIND(dev_priv, RV515_MC_FB_LOCATION); - else if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) + else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740)) return RS690_READ_MCIND(dev_priv, RS690_MC_FB_LOCATION); else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515) return R500_READ_MCIND(dev_priv, R520_MC_FB_LOCATION); @@ -96,7 +98,8 @@ static void radeon_write_fb_location(drm { if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515) R500_WRITE_MCIND(RV515_MC_FB_LOCATION, fb_loc); - else if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) + else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740)) RS690_WRITE_MCIND(RS690_MC_FB_LOCATION, fb_loc); else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515) R500_WRITE_MCIND(R520_MC_FB_LOCATION, fb_loc); @@ -108,7 +111,8 @@ static void radeon_write_agp_location(dr { if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515) R500_WRITE_MCIND(RV515_MC_AGP_LOCATION, agp_loc); - else if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) + else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740)) RS690_WRITE_MCIND(RS690_MC_AGP_LOCATION, agp_loc); else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515) R500_WRITE_MCIND(R520_MC_AGP_LOCATION, agp_loc); @@ -124,7 +128,8 @@ static void radeon_write_agp_base(drm_ra if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515) { R500_WRITE_MCIND(RV515_MC_AGP_BASE, agp_base_lo); R500_WRITE_MCIND(RV515_MC_AGP_BASE_2, agp_base_hi); - } else if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) { + } else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740)) { RS690_WRITE_MCIND(RS690_MC_AGP_BASE, agp_base_lo); RS690_WRITE_MCIND(RS690_MC_AGP_BASE_2, agp_base_hi); } else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515) { @@ -369,8 +374,9 @@ static void radeon_cp_load_microcode(drm RADEON_WRITE(RADEON_CP_ME_RAM_DATAL, R420_cp_microcode[i][0]); } - } else if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) { - DRM_INFO("Loading RS690 Microcode\n"); + } else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740)) { + DRM_INFO("Loading RS690/RS740 Microcode\n"); for (i = 0; i < 256; i++) { RADEON_WRITE(RADEON_CP_ME_RAM_DATAH, RS690_cp_microcode[i][1]); @@ -721,7 +727,8 @@ static void radeon_set_igpgart(drm_radeo temp = IGP_READ_MCIND(dev_priv, RS480_MC_MISC_CNTL); - if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) + if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740)) IGP_WRITE_MCIND(RS480_MC_MISC_CNTL, (RS480_GART_INDEX_REG_EN | RS690_BLOCK_GFX_D3_EN)); else @@ -814,6 +821,7 @@ static void radeon_set_pcigart(drm_radeo u32 tmp; if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740) || (dev_priv->flags & RADEON_IS_IGPGART)) { radeon_set_igpgart(dev_priv, on); return; Modified: head/sys/dev/drm/radeon_drv.h ============================================================================== --- head/sys/dev/drm/radeon_drv.h Mon Oct 13 17:33:55 2008 (r183827) +++ head/sys/dev/drm/radeon_drv.h Mon Oct 13 17:38:04 2008 (r183828) @@ -130,6 +130,7 @@ enum radeon_family { CHIP_RS400, CHIP_RS480, CHIP_RS690, + CHIP_RS740, CHIP_RV515, CHIP_R520, CHIP_RV530, @@ -1235,7 +1236,8 @@ do { \ #define IGP_WRITE_MCIND( addr, val ) \ do { \ - if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) \ + if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) || \ + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740)) \ RS690_WRITE_MCIND( addr, val ); \ else \ RS480_WRITE_MCIND( addr, val ); \ From kensmith at FreeBSD.org Mon Oct 13 17:42:22 2008 From: kensmith at FreeBSD.org (Ken Smith) Date: Mon Oct 13 17:42:33 2008 Subject: svn commit: r183829 - head/release/scripts Message-ID: <200810131742.m9DHgMeB082020@svn.freebsd.org> Author: kensmith Date: Mon Oct 13 17:42:21 2008 New Revision: 183829 URL: http://svn.freebsd.org/changeset/base/183829 Log: Fix minor typo. Modified: head/release/scripts/package-trees.sh Modified: head/release/scripts/package-trees.sh ============================================================================== --- head/release/scripts/package-trees.sh Mon Oct 13 17:38:04 2008 (r183828) +++ head/release/scripts/package-trees.sh Mon Oct 13 17:42:21 2008 (r183829) @@ -5,7 +5,7 @@ # contains the master INDEX, it's assigned list of packages, and the # appropriate tree of category symlinks. # -# Usage: package-tress.sh +# Usage: package-trees.sh # # $FreeBSD$ From rnoland at FreeBSD.org Mon Oct 13 17:43:40 2008 From: rnoland at FreeBSD.org (Robert Noland) Date: Mon Oct 13 17:43:47 2008 Subject: svn commit: r183830 - head/sys/dev/drm Message-ID: <200810131743.m9DHheBc082080@svn.freebsd.org> Author: rnoland Date: Mon Oct 13 17:43:39 2008 New Revision: 183830 URL: http://svn.freebsd.org/changeset/base/183830 Log: Several of the newer radeon cards have moved around the registers for enabling busmastering support. This also adds register definitions for MSI support, which we will be using shortly. Approved by: jhb (mentor) Obtained from: drm git master Modified: head/sys/dev/drm/drm_pciids.h head/sys/dev/drm/radeon_cp.c head/sys/dev/drm/radeon_drv.h Modified: head/sys/dev/drm/drm_pciids.h ============================================================================== --- head/sys/dev/drm/drm_pciids.h Mon Oct 13 17:42:21 2008 (r183829) +++ head/sys/dev/drm/drm_pciids.h Mon Oct 13 17:43:39 2008 (r183830) @@ -86,18 +86,18 @@ {0x1002, 0x5460, CHIP_RV380|RADEON_IS_MOBILITY, "ATI Radeon Mobility X300 M22"}, \ {0x1002, 0x5462, CHIP_RV380|RADEON_IS_MOBILITY, "ATI Radeon Mobility X600 SE M24C"}, \ {0x1002, 0x5464, CHIP_RV380|RADEON_IS_MOBILITY, "ATI FireGL M22 GL 5464"}, \ - {0x1002, 0x5548, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800"}, \ - {0x1002, 0x5549, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800 Pro"}, \ - {0x1002, 0x554A, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800 XT PE"}, \ - {0x1002, 0x554B, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800 SE"}, \ - {0x1002, 0x554C, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R430 X800 XTP"}, \ - {0x1002, 0x554D, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R430 X800 XL"}, \ - {0x1002, 0x554E, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R430 X800 SE"}, \ - {0x1002, 0x554F, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R430 X800"}, \ - {0x1002, 0x5550, CHIP_R420|RADEON_NEW_MEMMAP, "ATI FireGL V7100 R423"}, \ - {0x1002, 0x5551, CHIP_R420|RADEON_NEW_MEMMAP, "ATI FireGL V5100 R423 UQ"}, \ - {0x1002, 0x5552, CHIP_R420|RADEON_NEW_MEMMAP, "ATI FireGL unknown R423 UR"}, \ - {0x1002, 0x5554, CHIP_R420|RADEON_NEW_MEMMAP, "ATI FireGL unknown R423 UT"}, \ + {0x1002, 0x5548, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800"}, \ + {0x1002, 0x5549, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800 Pro"}, \ + {0x1002, 0x554A, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800 XT PE"}, \ + {0x1002, 0x554B, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800 SE"}, \ + {0x1002, 0x554C, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R430 X800 XTP"}, \ + {0x1002, 0x554D, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R430 X800 XL"}, \ + {0x1002, 0x554E, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R430 X800 SE"}, \ + {0x1002, 0x554F, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R430 X800"}, \ + {0x1002, 0x5550, CHIP_R423|RADEON_NEW_MEMMAP, "ATI FireGL V7100 R423"}, \ + {0x1002, 0x5551, CHIP_R423|RADEON_NEW_MEMMAP, "ATI FireGL V5100 R423 UQ"}, \ + {0x1002, 0x5552, CHIP_R423|RADEON_NEW_MEMMAP, "ATI FireGL unknown R423 UR"}, \ + {0x1002, 0x5554, CHIP_R423|RADEON_NEW_MEMMAP, "ATI FireGL unknown R423 UT"}, \ {0x1002, 0x564A, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility FireGL V5000 M26"}, \ {0x1002, 0x564B, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility FireGL V5000 M26"}, \ {0x1002, 0x564F, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Radeon Mobility X700 XL M26"}, \ @@ -127,16 +127,16 @@ {0x1002, 0x5b65, CHIP_RV380|RADEON_NEW_MEMMAP, "ATI FireMV 2200 PCIE (RV370) 5B65"}, \ {0x1002, 0x5c61, CHIP_RV280|RADEON_IS_MOBILITY, "ATI Radeon RV280 Mobility"}, \ {0x1002, 0x5c63, CHIP_RV280|RADEON_IS_MOBILITY, "ATI Radeon RV280 Mobility"}, \ - {0x1002, 0x5d48, CHIP_R420|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon X800 XT M28"}, \ - {0x1002, 0x5d49, CHIP_R420|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility FireGL V5100 M28"}, \ - {0x1002, 0x5d4a, CHIP_R420|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon X800 M28"}, \ - {0x1002, 0x5d4c, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R480 X850"}, \ - {0x1002, 0x5d4d, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R480 X850 XT PE"}, \ - {0x1002, 0x5d4e, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R480 X850 SE"}, \ - {0x1002, 0x5d4f, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R480 X850 Pro"}, \ - {0x1002, 0x5d50, CHIP_R420|RADEON_NEW_MEMMAP, "ATI unknown Radeon / FireGL R480"}, \ - {0x1002, 0x5d52, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R480 X850 XT"}, \ - {0x1002, 0x5d57, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800 XT"}, \ + {0x1002, 0x5d48, CHIP_R423|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon X800 XT M28"}, \ + {0x1002, 0x5d49, CHIP_R423|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility FireGL V5100 M28"}, \ + {0x1002, 0x5d4a, CHIP_R423|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon X800 M28"}, \ + {0x1002, 0x5d4c, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R480 X850"}, \ + {0x1002, 0x5d4d, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R480 X850 XT PE"}, \ + {0x1002, 0x5d4e, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R480 X850 SE"}, \ + {0x1002, 0x5d4f, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R480 X850 Pro"}, \ + {0x1002, 0x5d50, CHIP_R423|RADEON_NEW_MEMMAP, "ATI unknown Radeon / FireGL R480"}, \ + {0x1002, 0x5d52, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R480 X850 XT"}, \ + {0x1002, 0x5d57, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800 XT"}, \ {0x1002, 0x5e48, CHIP_RV410|RADEON_NEW_MEMMAP, "ATI FireGL V5000 RV410"}, \ {0x1002, 0x5e4a, CHIP_RV410|RADEON_NEW_MEMMAP, "ATI Radeon RV410 X700 XT"}, \ {0x1002, 0x5e4b, CHIP_RV410|RADEON_NEW_MEMMAP, "ATI Radeon RV410 X700 Pro"}, \ Modified: head/sys/dev/drm/radeon_cp.c ============================================================================== --- head/sys/dev/drm/radeon_cp.c Mon Oct 13 17:42:21 2008 (r183829) +++ head/sys/dev/drm/radeon_cp.c Mon Oct 13 17:43:39 2008 (r183830) @@ -366,6 +366,7 @@ static void radeon_cp_load_microcode(drm R300_cp_microcode[i][0]); } } else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R420) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R423) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV410)) { DRM_INFO("Loading R400 Microcode\n"); for (i = 0; i < 256; i++) { @@ -654,8 +655,18 @@ static void radeon_cp_init_ring_buffer(s RADEON_WRITE(RADEON_SCRATCH_UMSK, 0x7); /* Turn on bus mastering */ - tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RADEON_BUS_MASTER_DIS; - RADEON_WRITE(RADEON_BUS_CNTL, tmp); + if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS400) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740)) { + /* rs400, rs690/rs740 */ + tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RS400_BUS_MASTER_DIS; + RADEON_WRITE(RADEON_BUS_CNTL, tmp); + } else if (!(((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV380) || + ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R423))) { + /* r1xx, r2xx, r300, r(v)350, r420/r481, rs480 */ + tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RADEON_BUS_MASTER_DIS; + RADEON_WRITE(RADEON_BUS_CNTL, tmp); + } /* PCIE cards appears to not need this */ dev_priv->sarea_priv->last_frame = dev_priv->scratch[0] = 0; RADEON_WRITE(RADEON_LAST_FRAME_REG, dev_priv->sarea_priv->last_frame); @@ -1718,6 +1729,7 @@ int radeon_driver_load(struct drm_device case CHIP_R300: case CHIP_R350: case CHIP_R420: + case CHIP_R423: case CHIP_RV410: case CHIP_RV515: case CHIP_R520: Modified: head/sys/dev/drm/radeon_drv.h ============================================================================== --- head/sys/dev/drm/radeon_drv.h Mon Oct 13 17:42:21 2008 (r183829) +++ head/sys/dev/drm/radeon_drv.h Mon Oct 13 17:43:39 2008 (r183830) @@ -126,6 +126,7 @@ enum radeon_family { CHIP_RV350, CHIP_RV380, CHIP_R420, + CHIP_R423, CHIP_RV410, CHIP_RS400, CHIP_RS480, @@ -434,8 +435,31 @@ extern int r300_do_cp_cmdbuf(struct drm_ # define RADEON_SCISSOR_1_ENABLE (1 << 29) # define RADEON_SCISSOR_2_ENABLE (1 << 30) +/* + * PCIE radeons (rv370/rv380, rv410, r423/r430/r480, r5xx) + * don't have an explicit bus mastering disable bit. It's handled + * by the PCI D-states. PMI_BM_DIS disables D-state bus master + * handling, not bus mastering itself. + */ #define RADEON_BUS_CNTL 0x0030 +/* r1xx, r2xx, r300, r(v)350, r420/r481, rs480 */ # define RADEON_BUS_MASTER_DIS (1 << 6) +/* rs400, rs690/rs740 */ +# define RS400_BUS_MASTER_DIS (1 << 14) +# define RS400_MSI_REARM (1 << 20) +/* see RS480_MSI_REARM in AIC_CNTL for rs480 */ + +#define RADEON_BUS_CNTL1 0x0034 +# define RADEON_PMI_BM_DIS (1 << 2) +# define RADEON_PMI_INT_DIS (1 << 3) + +#define RV370_BUS_CNTL 0x004c +# define RV370_PMI_BM_DIS (1 << 5) +# define RV370_PMI_INT_DIS (1 << 6) + +#define RADEON_MSI_REARM_EN 0x0160 +/* rv370/rv380, rv410, r423/r430/r480, r5xx */ +# define RV370_MSI_REARM_EN (1 << 0) #define RADEON_CLOCK_CNTL_DATA 0x000c # define RADEON_PLL_WR_EN (1 << 7) @@ -915,6 +939,7 @@ extern int r300_do_cp_cmdbuf(struct drm_ #define RADEON_AIC_CNTL 0x01d0 # define RADEON_PCIGART_TRANSLATE_EN (1 << 0) +# define RS480_MSI_REARM (1 << 3) #define RADEON_AIC_STAT 0x01d4 #define RADEON_AIC_PT_BASE 0x01d8 #define RADEON_AIC_LO_ADDR 0x01dc From rnoland at FreeBSD.org Mon Oct 13 17:47:13 2008 From: rnoland at FreeBSD.org (Robert Noland) Date: Mon Oct 13 17:47:25 2008 Subject: svn commit: r183831 - head/sys/dev/drm Message-ID: <200810131747.m9DHlD5W082192@svn.freebsd.org> Author: rnoland Date: Mon Oct 13 17:47:13 2008 New Revision: 183831 URL: http://svn.freebsd.org/changeset/base/183831 Log: Correct the interrupt handling in the Intel i915 driver. Approved by: jhb (mentor) Modified: head/sys/dev/drm/i915_irq.c Modified: head/sys/dev/drm/i915_irq.c ============================================================================== --- head/sys/dev/drm/i915_irq.c Mon Oct 13 17:43:39 2008 (r183830) +++ head/sys/dev/drm/i915_irq.c Mon Oct 13 17:47:13 2008 (r183831) @@ -460,26 +460,31 @@ irqreturn_t i915_driver_irq_handler(DRM_ */ if (iir & I915_DISPLAY_PIPE_A_EVENT_INTERRUPT) { pipea_stats = I915_READ(PIPEASTAT); - if (pipea_stats & (PIPE_START_VBLANK_INTERRUPT_STATUS| - PIPE_VBLANK_INTERRUPT_STATUS)) + + /* The vblank interrupt gets enabled even if we didn't ask for + it, so make sure it's shut down again */ + if (!(dev_priv->vblank_pipe & DRM_I915_VBLANK_PIPE_A)) + pipea_stats &= ~(PIPE_START_VBLANK_INTERRUPT_ENABLE | + PIPE_VBLANK_INTERRUPT_ENABLE); + else if (pipea_stats & (PIPE_START_VBLANK_INTERRUPT_STATUS| + PIPE_VBLANK_INTERRUPT_STATUS)) { vblank++; drm_handle_vblank(dev, i915_get_plane(dev, 0)); } + I915_WRITE(PIPEASTAT, pipea_stats); } if (iir & I915_DISPLAY_PIPE_B_EVENT_INTERRUPT) { pipeb_stats = I915_READ(PIPEBSTAT); - /* Ack the event */ - I915_WRITE(PIPEBSTAT, pipeb_stats); /* The vblank interrupt gets enabled even if we didn't ask for it, so make sure it's shut down again */ if (!(dev_priv->vblank_pipe & DRM_I915_VBLANK_PIPE_B)) - pipeb_stats &= ~(I915_VBLANK_INTERRUPT_ENABLE); - - if (pipeb_stats & (PIPE_START_VBLANK_INTERRUPT_STATUS| - PIPE_VBLANK_INTERRUPT_STATUS)) + pipeb_stats &= ~(PIPE_START_VBLANK_INTERRUPT_ENABLE | + PIPE_VBLANK_INTERRUPT_ENABLE); + else if (pipeb_stats & (PIPE_START_VBLANK_INTERRUPT_STATUS| + PIPE_VBLANK_INTERRUPT_STATUS)) { vblank++; drm_handle_vblank(dev, i915_get_plane(dev, 1)); @@ -950,9 +955,9 @@ void i915_driver_irq_preinstall(struct d { drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; - I915_WRITE16(HWSTAM, 0xeffe); - I915_WRITE16(IMR, 0x0); - I915_WRITE16(IER, 0x0); + I915_WRITE(HWSTAM, 0xeffe); + I915_WRITE(IMR, 0xffffffff); + I915_WRITE(IER, 0x0); } int i915_driver_irq_postinstall(struct drm_device * dev) From rnoland at FreeBSD.org Mon Oct 13 17:52:43 2008 From: rnoland at FreeBSD.org (Robert Noland) Date: Mon Oct 13 17:52:49 2008 Subject: svn commit: r183832 - head/sys/dev/drm Message-ID: <200810131752.m9DHqgF7082322@svn.freebsd.org> Author: rnoland Date: Mon Oct 13 17:52:41 2008 New Revision: 183832 URL: http://svn.freebsd.org/changeset/base/183832 Log: The linux list compat code had an error which prevented list_for_each_safe() from operating on a list with a single item. This code is used much more by the i915 driver with xorg-7.4. Correct it to match the actual linux implementation. Approved by: jhb (mentor) Modified: head/sys/dev/drm/drm_linux_list.h Modified: head/sys/dev/drm/drm_linux_list.h ============================================================================== --- head/sys/dev/drm/drm_linux_list.h Mon Oct 13 17:47:13 2008 (r183831) +++ head/sys/dev/drm/drm_linux_list.h Mon Oct 13 17:52:41 2008 (r183832) @@ -69,6 +69,6 @@ list_del(struct list_head *entry) { #define list_for_each_safe(entry, temp, head) \ for (entry = (head)->next, temp = (entry)->next; \ - temp != head; \ - entry = temp, temp = temp->next) + entry != head; \ + entry = temp, temp = entry->next) From rnoland at FreeBSD.org Mon Oct 13 18:03:28 2008 From: rnoland at FreeBSD.org (Robert Noland) Date: Mon Oct 13 18:03:35 2008 Subject: svn commit: r183833 - head/sys/dev/drm Message-ID: <200810131803.m9DI3R1o082570@svn.freebsd.org> Author: rnoland Date: Mon Oct 13 18:03:27 2008 New Revision: 183833 URL: http://svn.freebsd.org/changeset/base/183833 Log: Rework memory allocation to allocate memory with different type names. This will ease the identification of memory leaks as the OS will be able to track allocations for us by malloc type. vmstat -m will show all of the allocations. Convert the calls to drm_alloc() and friends, which are used in shared code to static __inline__ while we are here. Approved by: jhb (mentor) Modified: head/sys/dev/drm/ati_pcigart.c head/sys/dev/drm/drmP.h head/sys/dev/drm/drm_agpsupport.c head/sys/dev/drm/drm_auth.c head/sys/dev/drm/drm_bufs.c head/sys/dev/drm/drm_context.c head/sys/dev/drm/drm_dma.c head/sys/dev/drm/drm_drv.c head/sys/dev/drm/drm_fops.c head/sys/dev/drm/drm_ioctl.c head/sys/dev/drm/drm_irq.c head/sys/dev/drm/drm_memory.c head/sys/dev/drm/drm_pci.c head/sys/dev/drm/drm_scatter.c head/sys/dev/drm/drm_sysctl.c head/sys/dev/drm/i915_drv.c head/sys/dev/drm/mach64_drv.c head/sys/dev/drm/mga_drv.c head/sys/dev/drm/r128_drv.c head/sys/dev/drm/radeon_drv.c head/sys/dev/drm/savage_drv.c head/sys/dev/drm/sis_drv.c head/sys/dev/drm/tdfx_drv.c Modified: head/sys/dev/drm/ati_pcigart.c ============================================================================== --- head/sys/dev/drm/ati_pcigart.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/ati_pcigart.c Mon Oct 13 18:03:27 2008 (r183833) @@ -64,7 +64,8 @@ drm_ati_alloc_pcigart_table(struct drm_d struct drm_dma_handle *dmah; int flags, ret; - dmah = malloc(sizeof(struct drm_dma_handle), M_DRM, M_ZERO | M_NOWAIT); + dmah = malloc(sizeof(struct drm_dma_handle), DRM_MEM_DMA, + M_ZERO | M_NOWAIT); if (dmah == NULL) return ENOMEM; @@ -77,7 +78,7 @@ drm_ati_alloc_pcigart_table(struct drm_d BUS_DMA_ALLOCNOW, NULL, NULL, /* flags, lockfunc, lockfuncargs */ &dmah->tag); if (ret != 0) { - free(dmah, M_DRM); + free(dmah, DRM_MEM_DMA); return ENOMEM; } @@ -88,7 +89,7 @@ drm_ati_alloc_pcigart_table(struct drm_d ret = bus_dmamem_alloc(dmah->tag, &dmah->vaddr, flags, &dmah->map); if (ret != 0) { bus_dma_tag_destroy(dmah->tag); - free(dmah, M_DRM); + free(dmah, DRM_MEM_DMA); return ENOMEM; } DRM_LOCK(); @@ -98,7 +99,7 @@ drm_ati_alloc_pcigart_table(struct drm_d if (ret != 0) { bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map); bus_dma_tag_destroy(dmah->tag); - free(dmah, M_DRM); + free(dmah, DRM_MEM_DMA); return ENOMEM; } @@ -115,7 +116,7 @@ drm_ati_free_pcigart_table(struct drm_de bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map); bus_dma_tag_destroy(dmah->tag); - free(dmah, M_DRM); + free(dmah, DRM_MEM_DMA); dev->sg->dmah = NULL; } Modified: head/sys/dev/drm/drmP.h ============================================================================== --- head/sys/dev/drm/drmP.h Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/drmP.h Mon Oct 13 18:03:27 2008 (r183833) @@ -129,27 +129,24 @@ struct drm_file; #define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */ #define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */ -#define DRM_MEM_DMA 0 -#define DRM_MEM_SAREA 1 -#define DRM_MEM_DRIVER 2 -#define DRM_MEM_MAGIC 3 -#define DRM_MEM_IOCTLS 4 -#define DRM_MEM_MAPS 5 -#define DRM_MEM_BUFS 6 -#define DRM_MEM_SEGS 7 -#define DRM_MEM_PAGES 8 -#define DRM_MEM_FILES 9 -#define DRM_MEM_QUEUES 10 -#define DRM_MEM_CMDS 11 -#define DRM_MEM_MAPPINGS 12 -#define DRM_MEM_BUFLISTS 13 -#define DRM_MEM_AGPLISTS 14 -#define DRM_MEM_TOTALAGP 15 -#define DRM_MEM_BOUNDAGP 16 -#define DRM_MEM_CTXBITMAP 17 -#define DRM_MEM_STUB 18 -#define DRM_MEM_SGLISTS 19 -#define DRM_MEM_DRAWABLE 20 +MALLOC_DECLARE(DRM_MEM_DMA); +MALLOC_DECLARE(DRM_MEM_SAREA); +MALLOC_DECLARE(DRM_MEM_DRIVER); +MALLOC_DECLARE(DRM_MEM_MAGIC); +MALLOC_DECLARE(DRM_MEM_IOCTLS); +MALLOC_DECLARE(DRM_MEM_MAPS); +MALLOC_DECLARE(DRM_MEM_BUFS); +MALLOC_DECLARE(DRM_MEM_SEGS); +MALLOC_DECLARE(DRM_MEM_PAGES); +MALLOC_DECLARE(DRM_MEM_FILES); +MALLOC_DECLARE(DRM_MEM_QUEUES); +MALLOC_DECLARE(DRM_MEM_CMDS); +MALLOC_DECLARE(DRM_MEM_MAPPINGS); +MALLOC_DECLARE(DRM_MEM_BUFLISTS); +MALLOC_DECLARE(DRM_MEM_AGPLISTS); +MALLOC_DECLARE(DRM_MEM_CTXBITMAP); +MALLOC_DECLARE(DRM_MEM_SGLISTS); +MALLOC_DECLARE(DRM_MEM_DRAWABLE); #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8) @@ -160,8 +157,6 @@ struct drm_file; #define DRM_IF_VERSION(maj, min) (maj << 16 | min) -MALLOC_DECLARE(M_DRM); - #define __OS_HAS_AGP 1 #define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) @@ -748,11 +743,6 @@ extern int drm_open_helper(struct cdev /* Memory management support (drm_memory.c) */ void drm_mem_init(void); void drm_mem_uninit(void); -void *drm_alloc(size_t size, int area); -void *drm_calloc(size_t nmemb, size_t size, int area); -void *drm_realloc(void *oldpt, size_t oldsize, size_t size, - int area); -void drm_free(void *pt, size_t size, int area); void *drm_ioremap_wc(struct drm_device *dev, drm_local_map_t *map); void *drm_ioremap(struct drm_device *dev, drm_local_map_t *map); void drm_ioremapfree(drm_local_map_t *map); @@ -966,6 +956,32 @@ drm_dma_handle_t *drm_pci_alloc(struct d size_t align, dma_addr_t maxaddr); void drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah); +/* Inline replacements for drm_alloc and friends */ +static __inline__ void * +drm_alloc(size_t size, struct malloc_type *area) +{ + return malloc(size, area, M_NOWAIT); +} + +static __inline__ void * +drm_calloc(size_t nmemb, size_t size, struct malloc_type *area) +{ + return malloc(size * nmemb, area, M_NOWAIT | M_ZERO); +} + +static __inline__ void * +drm_realloc(void *oldpt, size_t oldsize, size_t size, + struct malloc_type *area) +{ + return reallocf(oldpt, size, area, M_NOWAIT); +} + +static __inline__ void +drm_free(void *pt, size_t size, struct malloc_type *area) +{ + free(pt, area); +} + /* Inline replacements for DRM_IOREMAP macros */ static __inline__ void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev) Modified: head/sys/dev/drm/drm_agpsupport.c ============================================================================== --- head/sys/dev/drm/drm_agpsupport.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/drm_agpsupport.c Mon Oct 13 18:03:27 2008 (r183833) @@ -212,7 +212,7 @@ int drm_agp_alloc(struct drm_device *dev if (!dev->agp || !dev->agp->acquired) return EINVAL; - entry = malloc(sizeof(*entry), M_DRM, M_NOWAIT | M_ZERO); + entry = malloc(sizeof(*entry), DRM_MEM_AGPLISTS, M_NOWAIT | M_ZERO); if (entry == NULL) return ENOMEM; @@ -223,7 +223,7 @@ int drm_agp_alloc(struct drm_device *dev handle = drm_agp_allocate_memory(pages, type); DRM_LOCK(); if (handle == NULL) { - free(entry, M_DRM); + free(entry, DRM_MEM_AGPLISTS); return ENOMEM; } @@ -374,7 +374,7 @@ int drm_agp_free(struct drm_device *dev, drm_agp_free_memory(entry->handle); DRM_LOCK(); - free(entry, M_DRM); + free(entry, DRM_MEM_AGPLISTS); return 0; @@ -408,7 +408,8 @@ drm_agp_head_t *drm_agp_init(void) DRM_DEBUG("agp_available = %d\n", agp_available); if (agp_available) { - head = malloc(sizeof(*head), M_DRM, M_NOWAIT | M_ZERO); + head = malloc(sizeof(*head), DRM_MEM_AGPLISTS, + M_NOWAIT | M_ZERO); if (head == NULL) return NULL; head->agpdev = agpdev; Modified: head/sys/dev/drm/drm_auth.c ============================================================================== --- head/sys/dev/drm/drm_auth.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/drm_auth.c Mon Oct 13 18:03:27 2008 (r183833) @@ -77,7 +77,7 @@ static int drm_add_magic(struct drm_devi DRM_SPINLOCK_ASSERT(&dev->dev_lock); hash = drm_hash_magic(magic); - entry = malloc(sizeof(*entry), M_DRM, M_ZERO | M_NOWAIT); + entry = malloc(sizeof(*entry), DRM_MEM_MAGIC, M_ZERO | M_NOWAIT); if (!entry) return ENOMEM; entry->magic = magic; @@ -121,7 +121,7 @@ static int drm_remove_magic(struct drm_d if (prev) { prev->next = pt->next; } - free(pt, M_DRM); + free(pt, DRM_MEM_MAGIC); return 0; } } Modified: head/sys/dev/drm/drm_bufs.c ============================================================================== --- head/sys/dev/drm/drm_bufs.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/drm_bufs.c Mon Oct 13 18:03:27 2008 (r183833) @@ -138,7 +138,7 @@ int drm_addmap(struct drm_device * dev, /* Allocate a new map structure, fill it in, and do any type-specific * initialization necessary. */ - map = malloc(sizeof(*map), M_DRM, M_ZERO | M_NOWAIT); + map = malloc(sizeof(*map), DRM_MEM_MAPS, M_ZERO | M_NOWAIT); if (!map) { DRM_LOCK(); return ENOMEM; @@ -160,11 +160,11 @@ int drm_addmap(struct drm_device * dev, map->mtrr = 1; break; case _DRM_SHM: - map->handle = malloc(map->size, M_DRM, M_NOWAIT); + map->handle = malloc(map->size, DRM_MEM_MAPS, M_NOWAIT); DRM_DEBUG("%lu %d %p\n", map->size, drm_order(map->size), map->handle); if (!map->handle) { - free(map, M_DRM); + free(map, DRM_MEM_MAPS); DRM_LOCK(); return ENOMEM; } @@ -174,8 +174,8 @@ int drm_addmap(struct drm_device * dev, DRM_LOCK(); if (dev->lock.hw_lock != NULL) { DRM_UNLOCK(); - free(map->handle, M_DRM); - free(map, M_DRM); + free(map->handle, DRM_MEM_MAPS); + free(map, DRM_MEM_MAPS); return EBUSY; } dev->lock.hw_lock = map->handle; /* Pointer to lock */ @@ -205,14 +205,14 @@ int drm_addmap(struct drm_device * dev, } } if (!valid) { - free(map, M_DRM); + free(map, DRM_MEM_MAPS); DRM_LOCK(); return EACCES; }*/ break; case _DRM_SCATTER_GATHER: if (!dev->sg) { - free(map, M_DRM); + free(map, DRM_MEM_MAPS); DRM_LOCK(); return EINVAL; } @@ -230,7 +230,7 @@ int drm_addmap(struct drm_device * dev, align = PAGE_SIZE; map->dmah = drm_pci_alloc(dev, map->size, align, 0xfffffffful); if (map->dmah == NULL) { - free(map, M_DRM); + free(map, DRM_MEM_MAPS); DRM_LOCK(); return ENOMEM; } @@ -239,7 +239,7 @@ int drm_addmap(struct drm_device * dev, break; default: DRM_ERROR("Bad map type %d\n", map->type); - free(map, M_DRM); + free(map, DRM_MEM_MAPS); DRM_LOCK(); return EINVAL; } @@ -313,7 +313,7 @@ void drm_rmmap(struct drm_device *dev, d } break; case _DRM_SHM: - free(map->handle, M_DRM); + free(map->handle, DRM_MEM_MAPS); break; case _DRM_AGP: case _DRM_SCATTER_GATHER: @@ -331,7 +331,7 @@ void drm_rmmap(struct drm_device *dev, d map->bsr); } - free(map, M_DRM); + free(map, DRM_MEM_MAPS); } /* Remove a map private from list and deallocate resources if the mapping @@ -374,16 +374,16 @@ static void drm_cleanup_buf_error(struct for (i = 0; i < entry->seg_count; i++) { drm_pci_free(dev, entry->seglist[i]); } - free(entry->seglist, M_DRM); + free(entry->seglist, DRM_MEM_SEGS); entry->seg_count = 0; } if (entry->buf_count) { for (i = 0; i < entry->buf_count; i++) { - free(entry->buflist[i].dev_private, M_DRM); + free(entry->buflist[i].dev_private, DRM_MEM_BUFS); } - free(entry->buflist, M_DRM); + free(entry->buflist, DRM_MEM_BUFS); entry->buf_count = 0; } @@ -450,7 +450,7 @@ static int drm_do_addbufs_agp(struct drm entry = &dma->bufs[order]; - entry->buflist = malloc(count * sizeof(*entry->buflist), M_DRM, + entry->buflist = malloc(count * sizeof(*entry->buflist), DRM_MEM_BUFS, M_NOWAIT | M_ZERO); if (!entry->buflist) { return ENOMEM; @@ -476,7 +476,7 @@ static int drm_do_addbufs_agp(struct drm buf->file_priv = NULL; buf->dev_priv_size = dev->driver->buf_priv_size; - buf->dev_private = malloc(buf->dev_priv_size, M_DRM, + buf->dev_private = malloc(buf->dev_priv_size, DRM_MEM_BUFS, M_NOWAIT | M_ZERO); if (buf->dev_private == NULL) { /* Set count correctly so we free the proper amount. */ @@ -493,8 +493,8 @@ static int drm_do_addbufs_agp(struct drm DRM_DEBUG("byte_count: %d\n", byte_count); temp_buflist = realloc(dma->buflist, - (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM, - M_NOWAIT); + (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), + DRM_MEM_BUFS, M_NOWAIT); if (temp_buflist == NULL) { /* Free the entry because it isn't valid */ drm_cleanup_buf_error(dev, entry); @@ -552,22 +552,22 @@ static int drm_do_addbufs_pci(struct drm entry = &dma->bufs[order]; - entry->buflist = malloc(count * sizeof(*entry->buflist), M_DRM, + entry->buflist = malloc(count * sizeof(*entry->buflist), DRM_MEM_BUFS, M_NOWAIT | M_ZERO); - entry->seglist = malloc(count * sizeof(*entry->seglist), M_DRM, + entry->seglist = malloc(count * sizeof(*entry->seglist), DRM_MEM_SEGS, M_NOWAIT | M_ZERO); /* Keep the original pagelist until we know all the allocations * have succeeded */ temp_pagelist = malloc((dma->page_count + (count << page_order)) * - sizeof(*dma->pagelist), M_DRM, M_NOWAIT); + sizeof(*dma->pagelist), DRM_MEM_PAGES, M_NOWAIT); if (entry->buflist == NULL || entry->seglist == NULL || temp_pagelist == NULL) { - free(temp_pagelist, M_DRM); - free(entry->seglist, M_DRM); - free(entry->buflist, M_DRM); + free(temp_pagelist, DRM_MEM_PAGES); + free(entry->seglist, DRM_MEM_SEGS); + free(entry->buflist, DRM_MEM_BUFS); return ENOMEM; } @@ -592,7 +592,7 @@ static int drm_do_addbufs_pci(struct drm entry->buf_count = count; entry->seg_count = count; drm_cleanup_buf_error(dev, entry); - free(temp_pagelist, M_DRM); + free(temp_pagelist, DRM_MEM_PAGES); return ENOMEM; } @@ -620,14 +620,14 @@ static int drm_do_addbufs_pci(struct drm buf->file_priv = NULL; buf->dev_priv_size = dev->driver->buf_priv_size; - buf->dev_private = malloc(buf->dev_priv_size, M_DRM, - M_NOWAIT | M_ZERO); + buf->dev_private = malloc(buf->dev_priv_size, + DRM_MEM_BUFS, M_NOWAIT | M_ZERO); if (buf->dev_private == NULL) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; entry->seg_count = count; drm_cleanup_buf_error(dev, entry); - free(temp_pagelist, M_DRM); + free(temp_pagelist, DRM_MEM_PAGES); return ENOMEM; } @@ -638,12 +638,12 @@ static int drm_do_addbufs_pci(struct drm } temp_buflist = realloc(dma->buflist, - (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM, - M_NOWAIT); + (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), + DRM_MEM_BUFS, M_NOWAIT); if (temp_buflist == NULL) { /* Free the entry because it isn't valid */ drm_cleanup_buf_error(dev, entry); - free(temp_pagelist, M_DRM); + free(temp_pagelist, DRM_MEM_PAGES); return ENOMEM; } dma->buflist = temp_buflist; @@ -655,7 +655,7 @@ static int drm_do_addbufs_pci(struct drm /* No allocations failed, so now we can replace the orginal pagelist * with the new one. */ - free(dma->pagelist, M_DRM); + free(dma->pagelist, DRM_MEM_PAGES); dma->pagelist = temp_pagelist; dma->buf_count += entry->buf_count; @@ -709,7 +709,7 @@ static int drm_do_addbufs_sg(struct drm_ entry = &dma->bufs[order]; - entry->buflist = malloc(count * sizeof(*entry->buflist), M_DRM, + entry->buflist = malloc(count * sizeof(*entry->buflist), DRM_MEM_BUFS, M_NOWAIT | M_ZERO); if (entry->buflist == NULL) return ENOMEM; @@ -734,7 +734,7 @@ static int drm_do_addbufs_sg(struct drm_ buf->file_priv = NULL; buf->dev_priv_size = dev->driver->buf_priv_size; - buf->dev_private = malloc(buf->dev_priv_size, M_DRM, + buf->dev_private = malloc(buf->dev_priv_size, DRM_MEM_BUFS, M_NOWAIT | M_ZERO); if (buf->dev_private == NULL) { /* Set count correctly so we free the proper amount. */ @@ -754,8 +754,8 @@ static int drm_do_addbufs_sg(struct drm_ DRM_DEBUG("byte_count: %d\n", byte_count); temp_buflist = realloc(dma->buflist, - (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM, - M_NOWAIT); + (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), + DRM_MEM_BUFS, M_NOWAIT); if (temp_buflist == NULL) { /* Free the entry because it isn't valid */ drm_cleanup_buf_error(dev, entry); Modified: head/sys/dev/drm/drm_context.c ============================================================================== --- head/sys/dev/drm/drm_context.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/drm_context.c Mon Oct 13 18:03:27 2008 (r183833) @@ -80,7 +80,7 @@ int drm_ctxbitmap_next(struct drm_device ctx_sareas = realloc(dev->context_sareas, dev->max_context * sizeof(*dev->context_sareas), - M_DRM, M_NOWAIT); + DRM_MEM_SAREA, M_NOWAIT); if (ctx_sareas == NULL) { clear_bit(bit, dev->ctx_bitmap); DRM_UNLOCK(); @@ -91,7 +91,8 @@ int drm_ctxbitmap_next(struct drm_device } else { /* max_context == 1 at this point */ dev->context_sareas = malloc(dev->max_context * - sizeof(*dev->context_sareas), M_DRM, M_NOWAIT); + sizeof(*dev->context_sareas), DRM_MEM_SAREA, + M_NOWAIT); if (dev->context_sareas == NULL) { clear_bit(bit, dev->ctx_bitmap); DRM_UNLOCK(); @@ -110,7 +111,8 @@ int drm_ctxbitmap_init(struct drm_device int temp; DRM_LOCK(); - dev->ctx_bitmap = malloc(PAGE_SIZE, M_DRM, M_NOWAIT | M_ZERO); + dev->ctx_bitmap = malloc(PAGE_SIZE, DRM_MEM_CTXBITMAP, + M_NOWAIT | M_ZERO); if (dev->ctx_bitmap == NULL) { DRM_UNLOCK(); return ENOMEM; @@ -131,8 +133,8 @@ void drm_ctxbitmap_cleanup(struct drm_de { DRM_LOCK(); if (dev->context_sareas != NULL) - free(dev->context_sareas, M_DRM); - free(dev->ctx_bitmap, M_DRM); + free(dev->context_sareas, DRM_MEM_SAREA); + free(dev->ctx_bitmap, DRM_MEM_CTXBITMAP); DRM_UNLOCK(); } Modified: head/sys/dev/drm/drm_dma.c ============================================================================== --- head/sys/dev/drm/drm_dma.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/drm_dma.c Mon Oct 13 18:03:27 2008 (r183833) @@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$"); int drm_dma_setup(struct drm_device *dev) { - dev->dma = malloc(sizeof(*dev->dma), M_DRM, M_NOWAIT | M_ZERO); + dev->dma = malloc(sizeof(*dev->dma), DRM_MEM_DRIVER, M_NOWAIT | M_ZERO); if (dev->dma == NULL) return ENOMEM; @@ -70,21 +70,21 @@ void drm_dma_takedown(struct drm_device for (j = 0; j < dma->bufs[i].seg_count; j++) { drm_pci_free(dev, dma->bufs[i].seglist[j]); } - free(dma->bufs[i].seglist, M_DRM); + free(dma->bufs[i].seglist, DRM_MEM_SEGS); } if (dma->bufs[i].buf_count) { for (j = 0; j < dma->bufs[i].buf_count; j++) { free(dma->bufs[i].buflist[j].dev_private, - M_DRM); + DRM_MEM_BUFS); } - free(dma->bufs[i].buflist, M_DRM); + free(dma->bufs[i].buflist, DRM_MEM_BUFS); } } - free(dma->buflist, M_DRM); - free(dma->pagelist, M_DRM); - free(dev->dma, M_DRM); + free(dma->buflist, DRM_MEM_BUFS); + free(dma->pagelist, DRM_MEM_PAGES); + free(dev->dma, DRM_MEM_DRIVER); dev->dma = NULL; DRM_SPINUNINIT(&dev->dma_lock); } Modified: head/sys/dev/drm/drm_drv.c ============================================================================== --- head/sys/dev/drm/drm_drv.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/drm_drv.c Mon Oct 13 18:03:27 2008 (r183833) @@ -283,7 +283,7 @@ static int drm_lastclose(struct drm_devi drm_irq_uninstall(dev); if (dev->unique) { - free(dev->unique, M_DRM); + free(dev->unique, DRM_MEM_DRIVER); dev->unique = NULL; dev->unique_len = 0; } @@ -291,7 +291,7 @@ static int drm_lastclose(struct drm_devi for (i = 0; i < DRM_HASH_SIZE; i++) { for (pt = dev->magiclist[i].head; pt; pt = next) { next = pt->next; - free(pt, M_DRM); + free(pt, DRM_MEM_MAGIC); } dev->magiclist[i].head = dev->magiclist[i].tail = NULL; } @@ -313,7 +313,7 @@ static int drm_lastclose(struct drm_devi if (entry->bound) drm_agp_unbind_memory(entry->handle); drm_agp_free_memory(entry->handle); - free(entry, M_DRM); + free(entry, DRM_MEM_AGPLISTS); } dev->agp->memory = NULL; @@ -482,7 +482,7 @@ static void drm_unload(struct drm_device } if (dev->agp) { - free(dev->agp, M_DRM); + free(dev->agp, DRM_MEM_AGPLISTS); dev->agp = NULL; } @@ -626,7 +626,7 @@ void drm_close(void *data) if (dev->driver->postclose != NULL) dev->driver->postclose(dev, file_priv); TAILQ_REMOVE(&dev->files, file_priv, link); - free(file_priv, M_DRM); + free(file_priv, DRM_MEM_FILES); /* ======================================================== * End inline drm_release Modified: head/sys/dev/drm/drm_fops.c ============================================================================== --- head/sys/dev/drm/drm_fops.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/drm_fops.c Mon Oct 13 18:03:27 2008 (r183833) @@ -53,14 +53,14 @@ int drm_open_helper(struct cdev *kdev, i DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m); - priv = malloc(sizeof(*priv), M_DRM, M_NOWAIT | M_ZERO); + priv = malloc(sizeof(*priv), DRM_MEM_FILES, M_NOWAIT | M_ZERO); if (priv == NULL) { return ENOMEM; } retcode = devfs_set_cdevpriv(priv, drm_close); if (retcode != 0) { - free(priv, M_DRM); + free(priv, DRM_MEM_FILES); return retcode; } @@ -79,7 +79,7 @@ int drm_open_helper(struct cdev *kdev, i retcode = -dev->driver->open(dev, priv); if (retcode != 0) { devfs_clear_cdevpriv(); - free(priv, M_DRM); + free(priv, DRM_MEM_FILES); DRM_UNLOCK(); return retcode; } Modified: head/sys/dev/drm/drm_ioctl.c ============================================================================== --- head/sys/dev/drm/drm_ioctl.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/drm_ioctl.c Mon Oct 13 18:03:27 2008 (r183833) @@ -72,12 +72,12 @@ int drm_setunique(struct drm_device *dev if (!u->unique_len || u->unique_len > 1024) return EINVAL; - busid = malloc(u->unique_len + 1, M_DRM, M_WAITOK); + busid = malloc(u->unique_len + 1, DRM_MEM_DRIVER, M_WAITOK); if (busid == NULL) return ENOMEM; if (DRM_COPY_FROM_USER(busid, u->unique, u->unique_len)) { - free(busid, M_DRM); + free(busid, DRM_MEM_DRIVER); return EFAULT; } busid[u->unique_len] = '\0'; @@ -87,7 +87,7 @@ int drm_setunique(struct drm_device *dev */ ret = sscanf(busid, "PCI:%d:%d:%d", &bus, &slot, &func); if (ret != 3) { - free(busid, M_DRM); + free(busid, DRM_MEM_DRIVER); return EINVAL; } domain = bus >> 8; @@ -97,7 +97,7 @@ int drm_setunique(struct drm_device *dev (bus != dev->pci_bus) || (slot != dev->pci_slot) || (func != dev->pci_func)) { - free(busid, M_DRM); + free(busid, DRM_MEM_DRIVER); return EINVAL; } @@ -128,7 +128,7 @@ drm_set_busid(struct drm_device *dev) } dev->unique_len = 20; - dev->unique = malloc(dev->unique_len + 1, M_DRM, M_NOWAIT); + dev->unique = malloc(dev->unique_len + 1, DRM_MEM_DRIVER, M_NOWAIT); if (dev->unique == NULL) { DRM_UNLOCK(); return ENOMEM; Modified: head/sys/dev/drm/drm_irq.c ============================================================================== --- head/sys/dev/drm/drm_irq.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/drm_irq.c Mon Oct 13 18:03:27 2008 (r183833) @@ -114,8 +114,7 @@ static void drm_vblank_cleanup(struct dr vblank_disable_fn((void *)dev); - drm_free(dev->vblank, sizeof(struct drm_vblank_info) * dev->num_crtcs, - DRM_MEM_DRIVER); + free(dev->vblank, DRM_MEM_DRIVER); dev->num_crtcs = 0; } @@ -128,8 +127,8 @@ int drm_vblank_init(struct drm_device *d atomic_set(&dev->vbl_signal_pending, 0); dev->num_crtcs = num_crtcs; - dev->vblank = drm_calloc(num_crtcs, sizeof(struct drm_vblank_info), - DRM_MEM_DRIVER); + dev->vblank = malloc(sizeof(struct drm_vblank_info) * num_crtcs, + DRM_MEM_DRIVER, M_NOWAIT | M_ZERO); if (!dev->vblank) goto err; @@ -432,8 +431,8 @@ int drm_wait_vblank(struct drm_device *d if (flags & _DRM_VBLANK_SIGNAL) { #if 0 /* disabled */ - drm_vbl_sig_t *vbl_sig = malloc(sizeof(drm_vbl_sig_t), M_DRM, - M_NOWAIT | M_ZERO); + drm_vbl_sig_t *vbl_sig = malloc(sizeof(drm_vbl_sig_t), + DRM_MEM_DRIVER, M_NOWAIT | M_ZERO); if (vbl_sig == NULL) return ENOMEM; Modified: head/sys/dev/drm/drm_memory.c ============================================================================== --- head/sys/dev/drm/drm_memory.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/drm_memory.c Mon Oct 13 18:03:27 2008 (r183833) @@ -41,7 +41,25 @@ __FBSDID("$FreeBSD$"); #include "dev/drm/drmP.h" -MALLOC_DEFINE(M_DRM, "drm", "DRM Data Structures"); +MALLOC_DEFINE(DRM_MEM_DMA, "drm_dma", "DRM DMA Data Structures"); +MALLOC_DEFINE(DRM_MEM_SAREA, "drm_sarea", "DRM SAREA Data Structures"); +MALLOC_DEFINE(DRM_MEM_DRIVER, "drm_driver", "DRM DRIVER Data Structures"); +MALLOC_DEFINE(DRM_MEM_MAGIC, "drm_magic", "DRM MAGIC Data Structures"); +MALLOC_DEFINE(DRM_MEM_IOCTLS, "drm_ioctls", "DRM IOCTL Data Structures"); +MALLOC_DEFINE(DRM_MEM_MAPS, "drm_maps", "DRM MAP Data Structures"); +MALLOC_DEFINE(DRM_MEM_BUFS, "drm_bufs", "DRM BUFFER Data Structures"); +MALLOC_DEFINE(DRM_MEM_SEGS, "drm_segs", "DRM SEGMENTS Data Structures"); +MALLOC_DEFINE(DRM_MEM_PAGES, "drm_pages", "DRM PAGES Data Structures"); +MALLOC_DEFINE(DRM_MEM_FILES, "drm_files", "DRM FILE Data Structures"); +MALLOC_DEFINE(DRM_MEM_QUEUES, "drm_queues", "DRM QUEUE Data Structures"); +MALLOC_DEFINE(DRM_MEM_CMDS, "drm_cmds", "DRM COMMAND Data Structures"); +MALLOC_DEFINE(DRM_MEM_MAPPINGS, "drm_mapping", "DRM MAPPING Data Structures"); +MALLOC_DEFINE(DRM_MEM_BUFLISTS, "drm_buflists", "DRM BUFLISTS Data Structures"); +MALLOC_DEFINE(DRM_MEM_AGPLISTS, "drm_agplists", "DRM AGPLISTS Data Structures"); +MALLOC_DEFINE(DRM_MEM_CTXBITMAP, "drm_ctxbitmap", + "DRM CTXBITMAP Data Structures"); +MALLOC_DEFINE(DRM_MEM_SGLISTS, "drm_sglists", "DRM SGLISTS Data Structures"); +MALLOC_DEFINE(DRM_MEM_DRAWABLE, "drm_drawable", "DRM DRAWABLE Data Structures"); void drm_mem_init(void) { @@ -51,35 +69,6 @@ void drm_mem_uninit(void) { } -void *drm_alloc(size_t size, int area) -{ - return malloc(size, M_DRM, M_NOWAIT); -} - -void *drm_calloc(size_t nmemb, size_t size, int area) -{ - return malloc(size * nmemb, M_DRM, M_NOWAIT | M_ZERO); -} - -void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area) -{ - void *pt; - - pt = malloc(size, M_DRM, M_NOWAIT); - if (pt == NULL) - return NULL; - if (oldpt && oldsize) { - memcpy(pt, oldpt, DRM_MIN(oldsize,size)); - free(oldpt, M_DRM); - } - return pt; -} - -void drm_free(void *pt, size_t size, int area) -{ - free(pt, M_DRM); -} - void *drm_ioremap_wc(struct drm_device *dev, drm_local_map_t *map) { return pmap_mapdev_attr(map->offset, map->size, PAT_WRITE_COMBINING); Modified: head/sys/dev/drm/drm_pci.c ============================================================================== --- head/sys/dev/drm/drm_pci.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/drm_pci.c Mon Oct 13 18:03:27 2008 (r183833) @@ -67,7 +67,7 @@ drm_pci_alloc(struct drm_device *dev, si return NULL; } - dmah = malloc(sizeof(drm_dma_handle_t), M_DRM, M_ZERO | M_NOWAIT); + dmah = malloc(sizeof(drm_dma_handle_t), DRM_MEM_DMA, M_ZERO | M_NOWAIT); if (dmah == NULL) return NULL; @@ -86,7 +86,7 @@ drm_pci_alloc(struct drm_device *dev, si BUS_DMA_ALLOCNOW, NULL, NULL, /* flags, lockfunc, lockfuncargs */ &dmah->tag); if (ret != 0) { - free(dmah, M_DRM); + free(dmah, DRM_MEM_DMA); return NULL; } @@ -94,7 +94,7 @@ drm_pci_alloc(struct drm_device *dev, si &dmah->map); if (ret != 0) { bus_dma_tag_destroy(dmah->tag); - free(dmah, M_DRM); + free(dmah, DRM_MEM_DMA); return NULL; } @@ -103,7 +103,7 @@ drm_pci_alloc(struct drm_device *dev, si if (ret != 0) { bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map); bus_dma_tag_destroy(dmah->tag); - free(dmah, M_DRM); + free(dmah, DRM_MEM_DMA); return NULL; } @@ -122,7 +122,7 @@ drm_pci_free(struct drm_device *dev, drm bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map); bus_dma_tag_destroy(dmah->tag); - free(dmah, M_DRM); + free(dmah, DRM_MEM_DMA); } /*@}*/ Modified: head/sys/dev/drm/drm_scatter.c ============================================================================== --- head/sys/dev/drm/drm_scatter.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/drm_scatter.c Mon Oct 13 18:03:27 2008 (r183833) @@ -43,9 +43,9 @@ __FBSDID("$FreeBSD$"); void drm_sg_cleanup(drm_sg_mem_t *entry) { - free((void *)entry->handle, M_DRM); - free(entry->busaddr, M_DRM); - free(entry, M_DRM); + free((void *)entry->handle, DRM_MEM_PAGES); + free(entry->busaddr, DRM_MEM_PAGES); + free(entry, DRM_MEM_SGLISTS); } int drm_sg_alloc(struct drm_device * dev, struct drm_scatter_gather * request) @@ -57,7 +57,7 @@ int drm_sg_alloc(struct drm_device * dev if (dev->sg) return EINVAL; - entry = malloc(sizeof(*entry), M_DRM, M_WAITOK | M_ZERO); + entry = malloc(sizeof(*entry), DRM_MEM_SGLISTS, M_WAITOK | M_ZERO); if (!entry) return ENOMEM; @@ -66,14 +66,14 @@ int drm_sg_alloc(struct drm_device * dev entry->pages = pages; - entry->busaddr = malloc(pages * sizeof(*entry->busaddr), M_DRM, + entry->busaddr = malloc(pages * sizeof(*entry->busaddr), DRM_MEM_PAGES, M_WAITOK | M_ZERO); if (!entry->busaddr) { drm_sg_cleanup(entry); return ENOMEM; } - entry->handle = (long)malloc(pages << PAGE_SHIFT, M_DRM, + entry->handle = (long)malloc(pages << PAGE_SHIFT, DRM_MEM_PAGES, M_WAITOK | M_ZERO); if (entry->handle == 0) { drm_sg_cleanup(entry); Modified: head/sys/dev/drm/drm_sysctl.c ============================================================================== --- head/sys/dev/drm/drm_sysctl.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/drm_sysctl.c Mon Oct 13 18:03:27 2008 (r183833) @@ -62,7 +62,7 @@ int drm_sysctl_init(struct drm_device *d struct sysctl_oid *top, *drioid; int i; - info = malloc(sizeof *info, M_DRM, M_WAITOK | M_ZERO); + info = malloc(sizeof *info, DRM_MEM_DRIVER, M_WAITOK | M_ZERO); if ( !info ) return 1; dev->sysctl = info; @@ -114,7 +114,7 @@ int drm_sysctl_cleanup(struct drm_device int error; error = sysctl_ctx_free( &dev->sysctl->ctx ); - free(dev->sysctl, M_DRM); + free(dev->sysctl, DRM_MEM_DRIVER); dev->sysctl = NULL; return error; @@ -172,7 +172,8 @@ static int drm_vm_info DRM_SYSCTL_HANDLE TAILQ_FOREACH(map, &dev->maplist, link) mapcount++; - tempmaps = malloc(sizeof(drm_local_map_t) * mapcount, M_DRM, M_NOWAIT); + tempmaps = malloc(sizeof(drm_local_map_t) * mapcount, DRM_MEM_DRIVER, + M_NOWAIT); if (tempmaps == NULL) { DRM_UNLOCK(); return ENOMEM; @@ -208,7 +209,7 @@ static int drm_vm_info DRM_SYSCTL_HANDLE SYSCTL_OUT(req, "", 1); done: - free(tempmaps, M_DRM); + free(tempmaps, DRM_MEM_DRIVER); return retcode; } @@ -232,7 +233,8 @@ static int drm_bufs_info DRM_SYSCTL_HAND } DRM_SPINLOCK(&dev->dma_lock); tempdma = *dma; - templists = malloc(sizeof(int) * dma->buf_count, M_DRM, M_NOWAIT); + templists = malloc(sizeof(int) * dma->buf_count, DRM_MEM_DRIVER, + M_NOWAIT); for (i = 0; i < dma->buf_count; i++) templists[i] = dma->buflist[i]->list; dma = &tempdma; @@ -264,7 +266,7 @@ static int drm_bufs_info DRM_SYSCTL_HAND SYSCTL_OUT(req, "", 1); done: - free(templists, M_DRM); + free(templists, DRM_MEM_DRIVER); return retcode; } @@ -282,7 +284,8 @@ static int drm_clients_info DRM_SYSCTL_H TAILQ_FOREACH(priv, &dev->files, link) privcount++; - tempprivs = malloc(sizeof(struct drm_file) * privcount, M_DRM, M_NOWAIT); + tempprivs = malloc(sizeof(struct drm_file) * privcount, DRM_MEM_DRIVER, + M_NOWAIT); if (tempprivs == NULL) { DRM_UNLOCK(); return ENOMEM; @@ -307,6 +310,6 @@ static int drm_clients_info DRM_SYSCTL_H SYSCTL_OUT(req, "", 1); done: - free(tempprivs, M_DRM); + free(tempprivs, DRM_MEM_DRIVER); return retcode; } Modified: head/sys/dev/drm/i915_drv.c ============================================================================== --- head/sys/dev/drm/i915_drv.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/i915_drv.c Mon Oct 13 18:03:27 2008 (r183833) @@ -112,7 +112,7 @@ i915_attach(device_t nbdev) { struct drm_device *dev = device_get_softc(nbdev); - dev->driver = malloc(sizeof(struct drm_driver_info), M_DRM, + dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER, M_WAITOK | M_ZERO); i915_configure(dev); @@ -128,7 +128,7 @@ i915_detach(device_t nbdev) ret = drm_detach(nbdev); - free(dev->driver, M_DRM); + free(dev->driver, DRM_MEM_DRIVER); return ret; } Modified: head/sys/dev/drm/mach64_drv.c ============================================================================== --- head/sys/dev/drm/mach64_drv.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/mach64_drv.c Mon Oct 13 18:03:27 2008 (r183833) @@ -86,7 +86,7 @@ mach64_attach(device_t nbdev) { struct drm_device *dev = device_get_softc(nbdev); - dev->driver = malloc(sizeof(struct drm_driver_info), M_DRM, + dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER, M_WAITOK | M_ZERO); mach64_configure(dev); @@ -102,7 +102,7 @@ mach64_detach(device_t nbdev) ret = drm_detach(nbdev); - free(dev->driver, M_DRM); + free(dev->driver, DRM_MEM_DRIVER); return ret; } Modified: head/sys/dev/drm/mga_drv.c ============================================================================== --- head/sys/dev/drm/mga_drv.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/mga_drv.c Mon Oct 13 18:03:27 2008 (r183833) @@ -130,7 +130,7 @@ mga_attach(device_t nbdev) { struct drm_device *dev = device_get_softc(nbdev); - dev->driver = malloc(sizeof(struct drm_driver_info), M_DRM, + dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER, M_WAITOK | M_ZERO); mga_configure(dev); @@ -146,7 +146,7 @@ mga_detach(device_t nbdev) ret = drm_detach(nbdev); - free(dev->driver, M_DRM); + free(dev->driver, DRM_MEM_DRIVER); return ret; } Modified: head/sys/dev/drm/r128_drv.c ============================================================================== --- head/sys/dev/drm/r128_drv.c Mon Oct 13 17:52:41 2008 (r183832) +++ head/sys/dev/drm/r128_drv.c Mon Oct 13 18:03:27 2008 (r183833) @@ -85,7 +85,7 @@ r128_attach(device_t nbdev) { struct drm_device *dev = device_get_softc(nbdev); - dev->driver = malloc(sizeof(struct drm_driver_info), M_DRM, + dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER, M_WAITOK | M_ZERO); r128_configure(dev); @@ -101,7 +101,7 @@ r128_detach(device_t nbdev) ret = drm_detach(nbdev); - free(dev->driver, M_DRM); + free(dev->driver, DRM_MEM_DRIVER); return ret; } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From rnoland at FreeBSD.org Mon Oct 13 18:06:34 2008 From: rnoland at FreeBSD.org (Robert Noland) Date: Mon Oct 13 18:06:46 2008 Subject: svn commit: r183834 - head/sys/dev/drm Message-ID: <200810131806.m9DI6Yvw082678@svn.freebsd.org> Author: rnoland Date: Mon Oct 13 18:06:33 2008 New Revision: 183834 URL: http://svn.freebsd.org/changeset/base/183834 Log: Correct memory leak of info->rects. Previously we would free info, but but abandon info->rects. Approved by: jhb (mentor) Modified: head/sys/dev/drm/drm_drawable.c Modified: head/sys/dev/drm/drm_drawable.c ============================================================================== --- head/sys/dev/drm/drm_drawable.c Mon Oct 13 18:03:27 2008 (r183833) +++ head/sys/dev/drm/drm_drawable.c Mon Oct 13 18:06:33 2008 (r183834) @@ -74,8 +74,8 @@ int drm_adddraw(struct drm_device *dev, struct drm_draw *draw = data; struct bsd_drm_drawable_info *info; - info = drm_calloc(1, sizeof(struct bsd_drm_drawable_info), - DRM_MEM_DRAWABLE); + info = malloc(sizeof(struct bsd_drm_drawable_info), DRM_MEM_DRAWABLE, + M_NOWAIT | M_ZERO); if (info == NULL) return ENOMEM; @@ -102,8 +102,8 @@ int drm_rmdraw(struct drm_device *dev, v (struct bsd_drm_drawable_info *)info); DRM_SPINUNLOCK(&dev->drw_lock); free_unr(dev->drw_unrhdr, draw->handle); - drm_free(info, sizeof(struct bsd_drm_drawable_info), - DRM_MEM_DRAWABLE); + free(info->rects, DRM_MEM_DRAWABLE); + free(info, DRM_MEM_DRAWABLE); return 0; } else { DRM_SPINUNLOCK(&dev->drw_lock); @@ -126,9 +126,7 @@ int drm_update_draw(struct drm_device *d case DRM_DRAWABLE_CLIPRECTS: DRM_SPINLOCK(&dev->drw_lock); if (update->num != info->num_rects) { - drm_free(info->rects, - sizeof(*info->rects) * info->num_rects, - DRM_MEM_DRAWABLE); + free(info->rects, DRM_MEM_DRAWABLE); info->rects = NULL; info->num_rects = 0; } @@ -137,8 +135,8 @@ int drm_update_draw(struct drm_device *d return 0; } if (info->rects == NULL) { - info->rects = drm_alloc(sizeof(*info->rects) * - update->num, DRM_MEM_DRAWABLE); + info->rects = malloc(sizeof(*info->rects) * + update->num, DRM_MEM_DRAWABLE, M_NOWAIT); if (info->rects == NULL) { DRM_SPINUNLOCK(&dev->drw_lock); return ENOMEM; @@ -167,8 +165,8 @@ void drm_drawable_free_all(struct drm_de (struct bsd_drm_drawable_info *)info); DRM_SPINUNLOCK(&dev->drw_lock); free_unr(dev->drw_unrhdr, info->handle); - drm_free(info, sizeof(struct bsd_drm_drawable_info), - DRM_MEM_DRAWABLE); + free(info->info.rects, DRM_MEM_DRAWABLE); + free(info, DRM_MEM_DRAWABLE); DRM_SPINLOCK(&dev->drw_lock); } DRM_SPINUNLOCK(&dev->drw_lock); From raj at FreeBSD.org Mon Oct 13 18:16:55 2008 From: raj at FreeBSD.org (Rafal Jaworowski) Date: Mon Oct 13 18:17:02 2008 Subject: svn commit: r183835 - in head/sys/arm: arm include Message-ID: <200810131816.m9DIGtbT082936@svn.freebsd.org> Author: raj Date: Mon Oct 13 18:16:54 2008 New Revision: 183835 URL: http://svn.freebsd.org/changeset/base/183835 Log: Introduce low-level support for new Marvell core CPUs: 88FR131, 88FR571. They are compliant with ARMv5TE and integrated on 88F6281 (Kirkwood) and MV78100 (Discovery) system-on-chip families. Obtained from: Marvell, Semihalf Added: head/sys/arm/arm/cpufunc_asm_feroceon.S (contents, props changed) Modified: head/sys/arm/arm/cpufunc.c head/sys/arm/arm/identcpu.c head/sys/arm/include/armreg.h head/sys/arm/include/cpufunc.h Modified: head/sys/arm/arm/cpufunc.c ============================================================================== --- head/sys/arm/arm/cpufunc.c Mon Oct 13 18:06:33 2008 (r183834) +++ head/sys/arm/arm/cpufunc.c Mon Oct 13 18:16:54 2008 (r183835) @@ -357,6 +357,66 @@ struct cpu_functions armv5_ec_cpufuncs = arm10_setup /* cpu setup */ }; + +struct cpu_functions feroceon_cpufuncs = { + /* CPU functions */ + + cpufunc_id, /* id */ + cpufunc_nullop, /* cpwait */ + + /* MMU functions */ + + cpufunc_control, /* control */ + cpufunc_domains, /* Domain */ + feroceon_setttb, /* Setttb */ + cpufunc_faultstatus, /* Faultstatus */ + cpufunc_faultaddress, /* Faultaddress */ + + /* TLB functions */ + + armv4_tlb_flushID, /* tlb_flushID */ + arm10_tlb_flushID_SE, /* tlb_flushID_SE */ + armv4_tlb_flushI, /* tlb_flushI */ + arm10_tlb_flushI_SE, /* tlb_flushI_SE */ + armv4_tlb_flushD, /* tlb_flushD */ + armv4_tlb_flushD_SE, /* tlb_flushD_SE */ + + /* Cache operations */ + + armv5_ec_icache_sync_all, /* icache_sync_all */ + armv5_ec_icache_sync_range, /* icache_sync_range */ + + armv5_ec_dcache_wbinv_all, /* dcache_wbinv_all */ + feroceon_dcache_wbinv_range, /* dcache_wbinv_range */ + feroceon_dcache_inv_range, /* dcache_inv_range */ + feroceon_dcache_wb_range, /* dcache_wb_range */ + + armv5_ec_idcache_wbinv_all, /* idcache_wbinv_all */ + feroceon_idcache_wbinv_range, /* idcache_wbinv_all */ + + feroceon_l2cache_wbinv_all, /* l2cache_wbinv_all */ + feroceon_l2cache_wbinv_range, /* l2cache_wbinv_range */ + feroceon_l2cache_inv_range, /* l2cache_inv_range */ + feroceon_l2cache_wb_range, /* l2cache_wb_range */ + + /* Other functions */ + + cpufunc_nullop, /* flush_prefetchbuf */ + armv4_drain_writebuf, /* drain_writebuf */ + cpufunc_nullop, /* flush_brnchtgt_C */ + (void *)cpufunc_nullop, /* flush_brnchtgt_E */ + + (void *)cpufunc_nullop, /* sleep */ + + /* Soft functions */ + + cpufunc_null_fixup, /* dataabt_fixup */ + cpufunc_null_fixup, /* prefetchabt_fixup */ + + arm10_context_switch, /* context_switch */ + + arm10_setup /* cpu setup */ +}; #endif /* CPU_ARM9E || CPU_ARM10 */ #ifdef CPU_ARM10 @@ -933,9 +993,36 @@ set_cpufuncs() } #endif /* CPU_ARM9 */ #if defined(CPU_ARM9E) || defined(CPU_ARM10) - if (cputype == CPU_ID_ARM926EJS || - cputype == CPU_ID_ARM1026EJS) { - cpufuncs = armv5_ec_cpufuncs; + if (cputype == CPU_ID_ARM926EJS || cputype == CPU_ID_ARM1026EJS || + cputype == CPU_ID_MV88FR131 || cputype == CPU_ID_MV88FR571_VD || + cputype == CPU_ID_MV88FR571_41) { + if (cputype == CPU_ID_MV88FR131 || + cputype == CPU_ID_MV88FR571_VD || + cputype == CPU_ID_MV88FR571_41) { + + cpufuncs = feroceon_cpufuncs; + /* + * Workaround for Marvell MV78100 CPU: Cache prefetch + * mechanism may affect the cache coherency validity, + * so it needs to be disabled. + * + * Refer to errata document MV-S501058-00C.pdf (p. 3.1 + * L2 Prefetching Mechanism) for details. + */ + if (cputype == CPU_ID_MV88FR571_VD || + cputype == CPU_ID_MV88FR571_41) { + feroceon_control_ext(0xffffffff, + FC_DCACHE_STREAM_EN | FC_WR_ALLOC_EN | + FC_BRANCH_TARG_BUF_DIS | FC_L2CACHE_EN | + FC_L2_PREF_DIS); + } else { + feroceon_control_ext(0xffffffff, + FC_DCACHE_STREAM_EN | FC_WR_ALLOC_EN | + FC_BRANCH_TARG_BUF_DIS | FC_L2CACHE_EN); + } + } else + cpufuncs = armv5_ec_cpufuncs; + cpu_reset_needs_v4_MMU_disable = 1; /* V4 or higher */ get_cachetype_cp15(); pmap_pte_init_generic(); Added: head/sys/arm/arm/cpufunc_asm_feroceon.S ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm/arm/cpufunc_asm_feroceon.S Mon Oct 13 18:16:54 2008 (r183835) @@ -0,0 +1,386 @@ +/*- + * Copyright (C) 2008 MARVELL INTERNATIONAL LTD. + * All rights reserved. + * + * Developed by Semihalf. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of MARVELL nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +.Lferoceon_cache_line_size: + .word _C_LABEL(arm_pdcache_line_size) +.Lferoceon_asm_page_mask: + .word _C_LABEL(PAGE_MASK) + +ENTRY(feroceon_setttb) + /* Disable irqs */ + mrs r2, cpsr + orr r3, r2, #I32_bit | F32_bit + msr cpsr_c, r3 + + mov r1, #0 + mcr p15, 0, r1, c7, c5, 0 /* Invalidate ICache */ +1: mrc p15, 0, r15, c7, c14, 3 /* Test, clean and invalidate DCache */ + bne 1b /* More to do? */ + + mcr p15, 1, r1, c15, c9, 0 /* Clean L2 */ + mcr p15, 1, r1, c15, c11, 0 /* Invalidate L2 */ + + /* Reenable irqs */ + msr cpsr_c, r2 + + mcr p15, 0, r1, c7, c10, 4 /* drain the write buffer */ + + mcr p15, 0, r0, c2, c0, 0 /* load new TTB */ + + mcr p15, 0, r0, c8, c7, 0 /* invalidate I+D TLBs */ + RET + +ENTRY(feroceon_dcache_wbinv_range) + str lr, [sp, #-4]! + mrs lr, cpsr + /* Start with cache line aligned address */ + ldr ip, .Lferoceon_cache_line_size + ldr ip, [ip] + sub ip, ip, #1 + and r2, r0, ip + add r1, r1, r2 + add r1, r1, ip + bics r1, r1, ip + bics r0, r0, ip + + ldr ip, .Lferoceon_asm_page_mask + and r2, r0, ip + rsb r2, r2, #PAGE_SIZE + cmp r1, r2 + movcc ip, r1 + movcs ip, r2 +1: + add r3, r0, ip + sub r2, r3, #1 + /* Disable irqs */ + orr r3, lr, #I32_bit | F32_bit + msr cpsr_c, r3 + mcr p15, 5, r0, c15, c15, 0 /* Clean and inv zone start address */ + mcr p15, 5, r2, c15, c15, 1 /* Clean and inv zone end address */ + /* Enable irqs */ + msr cpsr_c, lr + + add r0, r0, ip + sub r1, r1, ip + cmp r1, #PAGE_SIZE + movcc ip, r1 + movcs ip, #PAGE_SIZE + cmp r1, #0 + bne 1b + mov r0, #0 + mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */ + ldr lr, [sp], #4 + RET + +ENTRY(feroceon_idcache_wbinv_range) + str lr, [sp, #-4]! + mrs lr, cpsr + /* Start with cache line aligned address */ + ldr ip, .Lferoceon_cache_line_size + ldr ip, [ip] + sub ip, ip, #1 + and r2, r0, ip + add r1, r1, r2 + add r1, r1, ip + bics r1, r1, ip + bics r0, r0, ip + + ldr ip, .Lferoceon_asm_page_mask + and r2, r0, ip + rsb r2, r2, #PAGE_SIZE + cmp r1, r2 + movcc ip, r1 + movcs ip, r2 +1: + add r3, r0, ip + sub r2, r3, #1 + /* Disable irqs */ + orr r3, lr, #I32_bit | F32_bit + msr cpsr_c, r3 + mcr p15, 5, r0, c15, c15, 0 /* Clean and inv zone start address */ + mcr p15, 5, r2, c15, c15, 1 /* Clean and inv zone end address */ + /* Enable irqs */ + msr cpsr_c, lr + + /* Invalidate and clean icache line by line */ + ldr r3, .Lferoceon_cache_line_size + ldr r3, [r3] +2: + mcr p15, 0, r0, c7, c5, 1 + add r0, r0, r3 + cmp r2, r0 + bhi 2b + + add r0, r2, #1 + sub r1, r1, ip + cmp r1, #PAGE_SIZE + movcc ip, r1 + movcs ip, #PAGE_SIZE + cmp r1, #0 + bne 1b + mov r0, #0 + mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */ + ldr lr, [sp], #4 + RET + +ENTRY(feroceon_dcache_inv_range) + str lr, [sp, #-4]! + mrs lr, cpsr + /* Start with cache line aligned address */ + ldr ip, .Lferoceon_cache_line_size + ldr ip, [ip] + sub ip, ip, #1 + and r2, r0, ip + add r1, r1, r2 + add r1, r1, ip + bics r1, r1, ip + bics r0, r0, ip + + ldr ip, .Lferoceon_asm_page_mask + and r2, r0, ip + rsb r2, r2, #PAGE_SIZE + cmp r1, r2 + movcc ip, r1 + movcs ip, r2 +1: + add r3, r0, ip + sub r2, r3, #1 + /* Disable irqs */ + orr r3, lr, #I32_bit | F32_bit + msr cpsr_c, r3 + mcr p15, 5, r0, c15, c14, 0 /* Inv zone start address */ + mcr p15, 5, r2, c15, c14, 1 /* Inv zone end address */ + /* Enable irqs */ + msr cpsr_c, lr + + add r0, r0, ip + sub r1, r1, ip + cmp r1, #PAGE_SIZE + movcc ip, r1 + movcs ip, #PAGE_SIZE + cmp r1, #0 + bne 1b + mov r0, #0 + mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */ + ldr lr, [sp], #4 + RET + +ENTRY(feroceon_dcache_wb_range) + str lr, [sp, #-4]! + mrs lr, cpsr + /* Start with cache line aligned address */ + ldr ip, .Lferoceon_cache_line_size + ldr ip, [ip] + sub ip, ip, #1 + and r2, r0, ip + add r1, r1, r2 + add r1, r1, ip + bics r1, r1, ip + bics r0, r0, ip + + ldr ip, .Lferoceon_asm_page_mask + and r2, r0, ip + rsb r2, r2, #PAGE_SIZE + cmp r1, r2 + movcc ip, r1 + movcs ip, r2 +1: + add r3, r0, ip + sub r2, r3, #1 + /* Disable irqs */ + orr r3, lr, #I32_bit | F32_bit + msr cpsr_c, r3 + mcr p15, 5, r0, c15, c13, 0 /* Clean zone start address */ + mcr p15, 5, r2, c15, c13, 1 /* Clean zone end address */ + /* Enable irqs */ + msr cpsr_c, lr + + add r0, r0, ip + sub r1, r1, ip + cmp r1, #PAGE_SIZE + movcc ip, r1 + movcs ip, #PAGE_SIZE + cmp r1, #0 + bne 1b + mov r0, #0 + mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */ + ldr lr, [sp], #4 + RET + +ENTRY(feroceon_l2cache_wbinv_range) + str lr, [sp, #-4]! + mrs lr, cpsr + /* Start with cache line aligned address */ + ldr ip, .Lferoceon_cache_line_size + ldr ip, [ip] + sub ip, ip, #1 + and r2, r0, ip + add r1, r1, r2 + add r1, r1, ip + bics r1, r1, ip + bics r0, r0, ip + + ldr ip, .Lferoceon_asm_page_mask + and r2, r0, ip + rsb r2, r2, #PAGE_SIZE + cmp r1, r2 + movcc ip, r1 + movcs ip, r2 +1: + add r3, r0, ip + sub r2, r3, #1 + /* Disable irqs */ + orr r3, lr, #I32_bit | F32_bit + msr cpsr_c, r3 + mcr p15, 1, r0, c15, c9, 4 /* Clean L2 zone start address */ + mcr p15, 1, r2, c15, c9, 5 /* Clean L2 zone end address */ + mcr p15, 1, r0, c15, c11, 4 /* Inv L2 zone start address */ + mcr p15, 1, r2, c15, c11, 5 /* Inv L2 zone end address */ + /* Enable irqs */ + msr cpsr_c, lr + + add r0, r0, ip + sub r1, r1, ip + cmp r1, #PAGE_SIZE + movcc ip, r1 + movcs ip, #PAGE_SIZE + cmp r1, #0 + bne 1b + mov r0, #0 + mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */ + ldr lr, [sp], #4 + RET + +ENTRY(feroceon_l2cache_inv_range) + str lr, [sp, #-4]! + mrs lr, cpsr + /* Start with cache line aligned address */ + ldr ip, .Lferoceon_cache_line_size + ldr ip, [ip] + sub ip, ip, #1 + and r2, r0, ip + add r1, r1, r2 + add r1, r1, ip + bics r1, r1, ip + bics r0, r0, ip + + ldr ip, .Lferoceon_asm_page_mask + and r2, r0, ip + rsb r2, r2, #PAGE_SIZE + cmp r1, r2 + movcc ip, r1 + movcs ip, r2 +1: + add r3, r0, ip + sub r2, r3, #1 + /* Disable irqs */ + orr r3, lr, #I32_bit | F32_bit + msr cpsr_c, r3 + mcr p15, 1, r0, c15, c11, 4 /* Inv L2 zone start address */ + mcr p15, 1, r2, c15, c11, 5 /* Inv L2 zone end address */ + /* Enable irqs */ + msr cpsr_c, lr + + add r0, r0, ip + sub r1, r1, ip + cmp r1, #PAGE_SIZE + movcc ip, r1 + movcs ip, #PAGE_SIZE + cmp r1, #0 + bne 1b + mov r0, #0 + mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */ + ldr lr, [sp], #4 + RET + +ENTRY(feroceon_l2cache_wb_range) + str lr, [sp, #-4]! + mrs lr, cpsr + /* Start with cache line aligned address */ + ldr ip, .Lferoceon_cache_line_size + ldr ip, [ip] + sub ip, ip, #1 + and r2, r0, ip + add r1, r1, r2 + add r1, r1, ip + bics r1, r1, ip + bics r0, r0, ip + + ldr ip, .Lferoceon_asm_page_mask + and r2, r0, ip + rsb r2, r2, #PAGE_SIZE + cmp r1, r2 + movcc ip, r1 + movcs ip, r2 +1: + add r3, r0, ip + sub r2, r3, #1 + /* Disable irqs */ + orr r3, lr, #I32_bit | F32_bit + msr cpsr_c, r3 + mcr p15, 1, r0, c15, c9, 4 /* Clean L2 zone start address */ + mcr p15, 1, r2, c15, c9, 5 /* Clean L2 zone end address */ + /* Enable irqs */ + msr cpsr_c, lr + + add r0, r0, ip + sub r1, r1, ip + cmp r1, #PAGE_SIZE + movcc ip, r1 + movcs ip, #PAGE_SIZE + cmp r1, #0 + bne 1b + mov r0, #0 + mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */ + ldr lr, [sp], #4 + RET + +ENTRY(feroceon_l2cache_wbinv_all) + mov r0, #0 + mcr p15, 1, r0, c15, c9, 0 /* Clean L2 */ + mcr p15, 1, r0, c15, c11, 0 /* Invalidate L2 */ + mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */ + RET + +ENTRY(feroceon_control_ext) + mrc p15, 1, r3, c15, c1, 0 /* Read the control register */ + bic r2, r3, r0 /* Clear bits */ + eor r2, r2, r1 /* XOR bits */ + + teq r2, r3 /* Only write if there is a change */ + mcrne p15, 1, r2, c15, c1, 0 /* Write new control register */ + mov r0, r3 /* Return old value */ + RET Modified: head/sys/arm/arm/identcpu.c ============================================================================== --- head/sys/arm/arm/identcpu.c Mon Oct 13 18:06:33 2008 (r183834) +++ head/sys/arm/arm/identcpu.c Mon Oct 13 18:16:54 2008 (r183835) @@ -75,7 +75,8 @@ enum cpu_class { CPU_CLASS_ARM10EJ, CPU_CLASS_SA1, CPU_CLASS_XSCALE, - CPU_CLASS_ARM11J + CPU_CLASS_ARM11J, + CPU_CLASS_MARVELL }; static const char * const generic_steppings[16] = { @@ -304,6 +305,15 @@ const struct cpuidtab cpuids[] = { { CPU_ID_ARM1136JSR1, CPU_CLASS_ARM11J, "ARM1136J-S R1", generic_steppings }, + { CPU_ID_MV88FR131, CPU_CLASS_MARVELL, "Feroceon 88FR131", + generic_steppings }, + + { CPU_ID_MV88FR571_VD, CPU_CLASS_MARVELL, "Feroceon 88FR571-VD", + generic_steppings }, + + { CPU_ID_MV88FR571_41, CPU_CLASS_MARVELL, "Early Feroceon 88FR571", + generic_steppings }, + { 0, CPU_CLASS_NONE, NULL, NULL } }; Modified: head/sys/arm/include/armreg.h ============================================================================== --- head/sys/arm/include/armreg.h Mon Oct 13 18:06:33 2008 (r183834) +++ head/sys/arm/include/armreg.h Mon Oct 13 18:16:54 2008 (r183835) @@ -148,6 +148,9 @@ #define CPU_ID_SA110 0x4401a100 #define CPU_ID_SA1100 0x4401a110 #define CPU_ID_TI925T 0x54029250 +#define CPU_ID_MV88FR131 0x56251310 /* Marvell Feroceon 88FR131 Core */ +#define CPU_ID_MV88FR571_VD 0x56155710 /* Marvell Feroceon 88FR571-VD Core (ID from datasheet) */ +#define CPU_ID_MV88FR571_41 0x41159260 /* Marvell Feroceon 88FR571-VD Core (actual ID from CPU reg) */ #define CPU_ID_FA526 0x66015260 #define CPU_ID_SA1110 0x6901b110 #define CPU_ID_IXP1200 0x6901c120 @@ -253,6 +256,18 @@ /* Xscale Core 3 only */ #define XSCALE_AUXCTL_LLR 0x00000400 /* Enable L2 for LLR Cache */ +/* Marvell Feroceon Extra Features Register (CP15 register 1, opcode2 0) */ +#define FC_DCACHE_REPL_LOCK 0x80000000 /* Replace DCache Lock */ +#define FC_DCACHE_STREAM_EN 0x20000000 /* DCache Streaming Switch */ +#define FC_WR_ALLOC_EN 0x10000000 /* Enable Write Allocate */ +#define FC_L2_PREF_DIS 0x01000000 /* L2 Cache Prefetch Disable */ +#define FC_L2_INV_EVICT_LINE 0x00800000 /* L2 Invalidates Uncorrectable Error Line Eviction */ +#define FC_L2CACHE_EN 0x00400000 /* L2 enable */ +#define FC_ICACHE_REPL_LOCK 0x00080000 /* Replace ICache Lock */ +#define FC_GLOB_HIST_REG_EN 0x00040000 /* Branch Global History Register Enable */ +#define FC_BRANCH_TARG_BUF_DIS 0x00020000 /* Branch Target Buffer Disable */ +#define FC_L1_PAR_ERR_EN 0x00010000 /* L1 Parity Error Enable */ + /* Cache type register definitions */ #define CPU_CT_ISIZE(x) ((x) & 0xfff) /* I$ info */ #define CPU_CT_DSIZE(x) (((x) >> 12) & 0xfff) /* D$ info */ Modified: head/sys/arm/include/cpufunc.h ============================================================================== --- head/sys/arm/include/cpufunc.h Mon Oct 13 18:06:33 2008 (r183834) +++ head/sys/arm/include/cpufunc.h Mon Oct 13 18:16:54 2008 (r183835) @@ -376,6 +376,18 @@ extern unsigned arm10_dcache_sets_max; extern unsigned arm10_dcache_sets_inc; extern unsigned arm10_dcache_index_max; extern unsigned arm10_dcache_index_inc; + +u_int feroceon_control_ext (u_int, u_int); +void feroceon_setttb (u_int); +void feroceon_dcache_wbinv_range (vm_offset_t, vm_size_t); +void feroceon_dcache_inv_range (vm_offset_t, vm_size_t); +void feroceon_dcache_wb_range (vm_offset_t, vm_size_t); +void feroceon_idcache_wbinv_range (vm_offset_t, vm_size_t); + +void feroceon_l2cache_wbinv_range (vm_offset_t, vm_size_t); +void feroceon_l2cache_inv_range (vm_offset_t, vm_size_t); +void feroceon_l2cache_wb_range (vm_offset_t, vm_size_t); +void feroceon_l2cache_wbinv_all (void); #endif #ifdef CPU_ARM11 From raj at FreeBSD.org Mon Oct 13 18:42:25 2008 From: raj at FreeBSD.org (Rafal Jaworowski) Date: Mon Oct 13 18:42:37 2008 Subject: svn commit: r183836 - head/sys/arm/arm Message-ID: <200810131842.m9DIgPkp083453@svn.freebsd.org> Author: raj Date: Mon Oct 13 18:42:25 2008 New Revision: 183836 URL: http://svn.freebsd.org/changeset/base/183836 Log: Do not use cached page for temporary mapping in pmap_zero_page_generic() The physical page which we clear is accessed via additional temp kernel mapping for the period of zeroing operation. However in systems with virtual d-cache (most ARMs) when write-allocate feature is enabled, we can have modified but unflushed content pertaining to this physical page still in the d-cache due to its primary (pre-existing) mapping. In such scenario that cached content upon flush is likely to overwrite [portions of] the physical page we want to zero here.. This is a general problem with multiple virtual mappings covering the same physical page with write-allocate and virtual d-cache: there is inherent potential for corruptions of this kind, which are not easily resolved; it is best policy that such multiple mappings be not allowed. Obtained from: Marvell, Semihalf Modified: head/sys/arm/arm/pmap.c Modified: head/sys/arm/arm/pmap.c ============================================================================== --- head/sys/arm/arm/pmap.c Mon Oct 13 18:16:54 2008 (r183835) +++ head/sys/arm/arm/pmap.c Mon Oct 13 18:42:25 2008 (r183836) @@ -3850,21 +3850,19 @@ pmap_zero_page_generic(vm_paddr_t phys, mtx_lock(&cmtx); /* - * Hook in the page, zero it, and purge the cache for that - * zeroed page. Invalidate the TLB as needed. + * Hook in the page, zero it, invalidate the TLB as needed. + * + * Note the temporary zero-page mapping must be a non-cached page in + * ordert to work without corruption when write-allocate is enabled. */ - *cdst_pte = L2_S_PROTO | phys | - L2_S_PROT(PTE_KERNEL, VM_PROT_WRITE) | pte_l2_s_cache_mode; - PTE_SYNC(cdst_pte); + *cdst_pte = L2_S_PROTO | phys | L2_S_PROT(PTE_KERNEL, VM_PROT_WRITE); cpu_tlb_flushD_SE(cdstp); cpu_cpwait(); - if (off || size != PAGE_SIZE) { + if (off || size != PAGE_SIZE) bzero((void *)(cdstp + off), size); - cpu_dcache_wbinv_range(cdstp + off, size); - } else { + else bzero_page(cdstp); - cpu_dcache_wbinv_range(cdstp, PAGE_SIZE); - } + mtx_unlock(&cmtx); #endif } From raj at FreeBSD.org Mon Oct 13 19:00:00 2008 From: raj at FreeBSD.org (Rafal Jaworowski) Date: Mon Oct 13 19:00:06 2008 Subject: svn commit: r183838 - head/sys/arm/arm Message-ID: <200810131859.m9DIxxgw083830@svn.freebsd.org> Author: raj Date: Mon Oct 13 18:59:59 2008 New Revision: 183838 URL: http://svn.freebsd.org/changeset/base/183838 Log: Provide L2 cache synchronization (write back + invalidation) on ARM. Note the cpu_l2cache_wbinv_* routines are no-ops on systems not populated with L2 caches. Obtained from: Marvell, Semihalf Modified: head/sys/arm/arm/busdma_machdep.c head/sys/arm/arm/elf_machdep.c head/sys/arm/arm/genassym.c head/sys/arm/arm/pmap.c head/sys/arm/arm/swtch.S Modified: head/sys/arm/arm/busdma_machdep.c ============================================================================== --- head/sys/arm/arm/busdma_machdep.c Mon Oct 13 18:44:59 2008 (r183837) +++ head/sys/arm/arm/busdma_machdep.c Mon Oct 13 18:59:59 2008 (r183838) @@ -629,6 +629,8 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, voi newmap->allocbuffer = tmpaddr; cpu_idcache_wbinv_range((vm_offset_t)*vaddr, dmat->maxsize); + cpu_l2cache_wbinv_range((vm_offset_t)*vaddr, + dmat->maxsize); *vaddr = tmpaddr; } else newmap->origbuffer = newmap->allocbuffer = NULL; Modified: head/sys/arm/arm/elf_machdep.c ============================================================================== --- head/sys/arm/arm/elf_machdep.c Mon Oct 13 18:44:59 2008 (r183837) +++ head/sys/arm/arm/elf_machdep.c Mon Oct 13 18:59:59 2008 (r183838) @@ -215,6 +215,7 @@ elf_cpu_load_file(linker_file_t lf __unu { cpu_idcache_wbinv_all(); + cpu_l2cache_wbinv_all(); cpu_tlb_flushID(); return (0); } Modified: head/sys/arm/arm/genassym.c ============================================================================== --- head/sys/arm/arm/genassym.c Mon Oct 13 18:44:59 2008 (r183837) +++ head/sys/arm/arm/genassym.c Mon Oct 13 18:59:59 2008 (r183838) @@ -79,7 +79,9 @@ ASSYM(CF_SETTTB, offsetof(struct cpu_fun ASSYM(CF_CONTROL, offsetof(struct cpu_functions, cf_control)); ASSYM(CF_CONTEXT_SWITCH, offsetof(struct cpu_functions, cf_context_switch)); ASSYM(CF_DCACHE_WB_RANGE, offsetof(struct cpu_functions, cf_dcache_wb_range)); +ASSYM(CF_L2CACHE_WB_RANGE, offsetof(struct cpu_functions, cf_l2cache_wb_range)); ASSYM(CF_IDCACHE_WBINV_ALL, offsetof(struct cpu_functions, cf_idcache_wbinv_all)); +ASSYM(CF_L2CACHE_WBINV_ALL, offsetof(struct cpu_functions, cf_l2cache_wbinv_all)); ASSYM(CF_TLB_FLUSHID_SE, offsetof(struct cpu_functions, cf_tlb_flushID_SE)); ASSYM(CF_ICACHE_SYNC, offsetof(struct cpu_functions, cf_icache_sync_all)); Modified: head/sys/arm/arm/pmap.c ============================================================================== --- head/sys/arm/arm/pmap.c Mon Oct 13 18:44:59 2008 (r183837) +++ head/sys/arm/arm/pmap.c Mon Oct 13 18:59:59 2008 (r183838) @@ -151,6 +151,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1196,27 +1197,104 @@ pmap_tlb_flushD(pmap_t pm) } static PMAP_INLINE void +pmap_l2cache_wbinv_range(pmap_t pm, vm_offset_t va, vm_size_t len) +{ + vm_size_t rest; + pd_entry_t *pde; + pt_entry_t *ptep; + + rest = MIN(PAGE_SIZE - (va & PAGE_MASK), len); + + while (len > 0) { + CTR4(KTR_PMAP, "pmap_l2cache_wbinv_range: pmap %p is_kernel %d " + "va 0x%08x len 0x%x ", pm, pm == pmap_kernel(), va, rest); + if (pmap_get_pde_pte(pm, va, &pde, &ptep) && l2pte_valid(*ptep)) + cpu_l2cache_wb_range(va, rest); + + len -= rest; + va += rest; + + rest = MIN(PAGE_SIZE, len); + } +} + +static PMAP_INLINE void pmap_idcache_wbinv_range(pmap_t pm, vm_offset_t va, vm_size_t len) { - if (pmap_is_current(pm)) + if (pmap_is_current(pm)) { cpu_idcache_wbinv_range(va, len); + pmap_l2cache_wbinv_range(pm, va, len); + } +} + +static PMAP_INLINE void +pmap_l2cache_wb_range(pmap_t pm, vm_offset_t va, vm_size_t len) +{ + vm_size_t rest; + pd_entry_t *pde; + pt_entry_t *ptep; + + rest = MIN(PAGE_SIZE - (va & PAGE_MASK), len); + + while (len > 0) { + CTR4(KTR_PMAP, "pmap_l2cache_wb_range: pmap %p is_kernel %d " + "va 0x%08x len 0x%x ", pm, pm == pmap_kernel(), va, rest); + if (pmap_get_pde_pte(pm, va, &pde, &ptep) && l2pte_valid(*ptep)) + cpu_l2cache_wb_range(va, rest); + + len -= rest; + va += rest; + + rest = MIN(PAGE_SIZE, len); + } } static PMAP_INLINE void -pmap_dcache_wb_range(pmap_t pm, vm_offset_t va, vm_size_t len, - boolean_t do_inv, boolean_t rd_only) +pmap_l2cache_inv_range(pmap_t pm, vm_offset_t va, vm_size_t len) { + vm_size_t rest; + pd_entry_t *pde; + pt_entry_t *ptep; + + rest = MIN(PAGE_SIZE - (va & PAGE_MASK), len); + + while (len > 0) { + CTR4(KTR_PMAP, "pmap_l2cache_wb_range: pmap %p is_kernel %d " + "va 0x%08x len 0x%x ", pm, pm == pmap_kernel(), va, rest); + if (pmap_get_pde_pte(pm, va, &pde, &ptep) && l2pte_valid(*ptep)) + cpu_l2cache_inv_range(va, rest); + + len -= rest; + va += rest; + + rest = MIN(PAGE_SIZE, len); + } +} + +static PMAP_INLINE void +pmap_dcache_wb_range(pmap_t pm, vm_offset_t va, vm_size_t len, boolean_t do_inv, + boolean_t rd_only) +{ + CTR4(KTR_PMAP, "pmap_dcache_wb_range: pmap %p is_kernel %d va 0x%08x " + "len 0x%x ", pm, pm == pmap_kernel(), va, len); + CTR2(KTR_PMAP, " do_inv %d rd_only %d", do_inv, rd_only); if (pmap_is_current(pm)) { if (do_inv) { - if (rd_only) + if (rd_only) { cpu_dcache_inv_range(va, len); - else + pmap_l2cache_inv_range(pm, va, len); + } + else { cpu_dcache_wbinv_range(va, len); + pmap_l2cache_wbinv_range(pm, va, len); + } } else - if (!rd_only) + if (!rd_only) { cpu_dcache_wb_range(va, len); + pmap_l2cache_wb_range(pm, va, len); + } } } @@ -1224,16 +1302,20 @@ static PMAP_INLINE void pmap_idcache_wbinv_all(pmap_t pm) { - if (pmap_is_current(pm)) + if (pmap_is_current(pm)) { cpu_idcache_wbinv_all(); + cpu_l2cache_wbinv_all(); + } } static PMAP_INLINE void pmap_dcache_wbinv_all(pmap_t pm) { - if (pmap_is_current(pm)) + if (pmap_is_current(pm)) { cpu_dcache_wbinv_all(); + cpu_l2cache_wbinv_all(); + } } /* @@ -2169,6 +2251,8 @@ pmap_set_pt_cache_mode(pd_entry_t *kl1, PTE_SYNC(pdep); cpu_dcache_wbinv_range((vm_offset_t)pdep, sizeof(*pdep)); + cpu_l2cache_wbinv_range((vm_offset_t)pdep, + sizeof(*pdep)); rv = 1; } } else { @@ -2185,6 +2269,8 @@ pmap_set_pt_cache_mode(pd_entry_t *kl1, PTE_SYNC(ptep); cpu_dcache_wbinv_range((vm_offset_t)ptep, sizeof(*ptep)); + cpu_l2cache_wbinv_range((vm_offset_t)ptep, + sizeof(*ptep)); rv = 1; } } @@ -2337,6 +2423,7 @@ pmap_bootstrap(vm_offset_t firstaddr, vm } cpu_dcache_wbinv_all(); + cpu_l2cache_wbinv_all(); cpu_tlb_flushID(); cpu_cpwait(); @@ -2373,6 +2460,7 @@ pmap_bootstrap(vm_offset_t firstaddr, vm mtx_init(&l1_lru_lock, "l1 list lock", NULL, MTX_DEF); pmap_init_l1(l1, kernel_l1pt); cpu_dcache_wbinv_all(); + cpu_l2cache_wbinv_all(); virtual_avail = round_page(virtual_avail); virtual_end = lastaddr; @@ -2402,6 +2490,7 @@ pmap_release(pmap_t pmap) struct pcb *pcb; pmap_idcache_wbinv_all(pmap); + cpu_l2cache_wbinv_all(); pmap_tlb_flushID(pmap); cpu_cpwait(); if (vector_page < KERNBASE) { @@ -2589,6 +2678,7 @@ pmap_growkernel(vm_offset_t addr) * rarely */ cpu_dcache_wbinv_all(); + cpu_l2cache_wbinv_all(); cpu_tlb_flushD(); cpu_cpwait(); kernel_vm_end = pmap_curmaxkvaddr; @@ -2614,6 +2704,7 @@ pmap_remove_pages(pmap_t pmap) vm_page_lock_queues(); PMAP_LOCK(pmap); cpu_idcache_wbinv_all(); + cpu_l2cache_wbinv_all(); for (pv = TAILQ_FIRST(&pmap->pm_pvlist); pv; pv = npv) { if (pv->pv_flags & PVF_WIRED) { /* The page is wired, cannot remove it now. */ @@ -2726,6 +2817,7 @@ pmap_kenter_internal(vm_offset_t va, vm_ (uint32_t) pte, opte, *pte)); if (l2pte_valid(opte)) { cpu_dcache_wbinv_range(va, PAGE_SIZE); + cpu_l2cache_wbinv_range(va, PAGE_SIZE); cpu_tlb_flushD_SE(va); cpu_cpwait(); } else { @@ -2784,6 +2876,7 @@ pmap_kremove(vm_offset_t va) opte = *pte; if (l2pte_valid(opte)) { cpu_dcache_wbinv_range(va, PAGE_SIZE); + cpu_l2cache_wbinv_range(va, PAGE_SIZE); cpu_tlb_flushD_SE(va); cpu_cpwait(); *pte = 0; @@ -3052,6 +3145,9 @@ pmap_protect(pmap_t pm, vm_offset_t sva, u_int flags; int flush; + CTR4(KTR_PMAP, "pmap_protect: pmap %p sva 0x%08x eva 0x%08x prot %x", + pm, sva, eva, prot); + if ((prot & VM_PROT_READ) == 0) { pmap_remove(pm, sva, eva); return; @@ -3286,9 +3382,11 @@ do_l2b_alloc: */ if (pmap_is_current(pmap) && (oflags & PVF_NC) == 0 && - (opte & L2_S_PROT_W) != 0 && - (prot & VM_PROT_WRITE) == 0) + (opte & L2_S_PROT_W) != 0 && + (prot & VM_PROT_WRITE) == 0) { cpu_dcache_wb_range(va, PAGE_SIZE); + pmap_l2cache_wb_range(pmap, va, PAGE_SIZE); + } } else { /* * New mapping, or changing the backing page @@ -3777,11 +3875,15 @@ pmap_remove(pmap_t pm, vm_offset_t sva, total++; if (is_exec) { cpu_idcache_wbinv_range(sva, - PAGE_SIZE); + PAGE_SIZE); + cpu_l2cache_wbinv_range(sva, + PAGE_SIZE); cpu_tlb_flushID_SE(sva); } else if (is_refd) { cpu_dcache_wbinv_range(sva, - PAGE_SIZE); + PAGE_SIZE); + cpu_l2cache_wbinv_range(sva, + PAGE_SIZE); cpu_tlb_flushD_SE(sva); } } else if (total == PMAP_REMOVE_CLEAN_LIST_SIZE) { @@ -3789,6 +3891,7 @@ pmap_remove(pmap_t pm, vm_offset_t sva, * for a current pmap */ cpu_idcache_wbinv_all(); + cpu_l2cache_wbinv_all(); flushall = 1; total++; } @@ -3842,9 +3945,11 @@ pmap_zero_page_generic(vm_paddr_t phys, if (off || size != PAGE_SIZE) { bzero(dstpg + off, size); cpu_dcache_wbinv_range((vm_offset_t)(dstpg + off), size); + cpu_l2cache_wbinv_range((vm_offset_t)(dstpg + off), size); } else { bzero_page((vm_offset_t)dstpg); cpu_dcache_wbinv_range((vm_offset_t)dstpg, PAGE_SIZE); + cpu_l2cache_wbinv_range((vm_offset_t)dstpg, PAGE_SIZE); } #else @@ -4139,6 +4244,8 @@ pmap_copy_page_generic(vm_paddr_t src, v mtx_unlock(&cmtx); cpu_dcache_inv_range(csrcp, PAGE_SIZE); cpu_dcache_wbinv_range(cdstp, PAGE_SIZE); + cpu_l2cache_inv_range(csrcp, PAGE_SIZE); + cpu_l2cache_wbinv_range(cdstp, PAGE_SIZE); } #endif /* (ARM_MMU_GENERIC + ARM_MMU_SA1) != 0 */ @@ -4201,6 +4308,7 @@ pmap_copy_page(vm_page_t src, vm_page_t #endif cpu_dcache_wbinv_all(); + cpu_l2cache_wbinv_all(); if (_arm_memcpy && PAGE_SIZE >= _min_memcpy_size && _arm_memcpy((void *)VM_PAGE_TO_PHYS(dst), (void *)VM_PAGE_TO_PHYS(src), PAGE_SIZE, IS_PHYSICAL) == 0) @@ -4210,6 +4318,7 @@ pmap_copy_page(vm_page_t src, vm_page_t dstpg = arm_ptovirt(VM_PAGE_TO_PHYS(dst)); bcopy_page(srcpg, dstpg); cpu_dcache_wbinv_range(dstpg, PAGE_SIZE); + cpu_l2cache_wbinv_range(dstpg, PAGE_SIZE); #else pmap_copy_page_func(VM_PAGE_TO_PHYS(src), VM_PAGE_TO_PHYS(dst)); #endif Modified: head/sys/arm/arm/swtch.S ============================================================================== --- head/sys/arm/arm/swtch.S Mon Oct 13 18:44:59 2008 (r183837) +++ head/sys/arm/arm/swtch.S Mon Oct 13 18:59:59 2008 (r183838) @@ -143,6 +143,8 @@ ENTRY(cpu_throw) ldr r9, .Lcpufuncs mov lr, pc ldr pc, [r9, #CF_IDCACHE_WBINV_ALL] + mov lr, pc + ldr pc, [r9, #CF_L2CACHE_WBINV_ALL] ldr r0, [r7, #(PCB_PL1VEC)] ldr r1, [r7, #(PCB_DACR)] /* @@ -172,6 +174,8 @@ ENTRY(cpu_throw) movne r1, #4 movne lr, pc ldrne pc, [r9, #CF_DCACHE_WB_RANGE] + movne lr, pc + ldrne pc, [r9, #CF_L2CACHE_WB_RANGE] #endif /* PMAP_INCLUDE_PTE_SYNC */ /* @@ -328,6 +332,8 @@ ENTRY(cpu_switch) ldr r1, .Lcpufuncs mov lr, pc ldr pc, [r1, #CF_IDCACHE_WBINV_ALL] + mov lr, pc + ldr pc, [r1, #CF_L2CACHE_WBINV_ALL] .Lcs_cache_purge_skipped: /* rem: r6 = lock */ /* rem: r9 = new PCB */ @@ -360,6 +366,8 @@ ENTRY(cpu_switch) mov r1, #4 mov lr, pc ldr pc, [r2, #CF_DCACHE_WB_RANGE] + mov lr, pc + ldr pc, [r2, #CF_L2CACHE_WB_RANGE] .Lcs_same_vector: #endif /* PMAP_INCLUDE_PTE_SYNC */ From raj at FreeBSD.org Mon Oct 13 19:14:14 2008 From: raj at FreeBSD.org (Rafal Jaworowski) Date: Mon Oct 13 19:14:20 2008 Subject: svn commit: r183839 - head/sys/arm/arm Message-ID: <200810131914.m9DJEEJN084115@svn.freebsd.org> Author: raj Date: Mon Oct 13 19:14:14 2008 New Revision: 183839 URL: http://svn.freebsd.org/changeset/base/183839 Log: One more L2 cache synchronization call that didn't make the previous commit. Modified: head/sys/arm/arm/locore.S Modified: head/sys/arm/arm/locore.S ============================================================================== --- head/sys/arm/arm/locore.S Mon Oct 13 18:59:59 2008 (r183838) +++ head/sys/arm/arm/locore.S Mon Oct 13 19:14:14 2008 (r183839) @@ -245,6 +245,8 @@ ENTRY_NP(cpu_halt) ldr r0, .Lcpufuncs mov lr, pc ldr pc, [r0, #CF_IDCACHE_WBINV_ALL] + mov lr, pc + ldr pc, [r0, #CF_L2CACHE_WBINV_ALL] /* * Load the cpu_reset_needs_v4_MMU_disable flag to determine if it's From raj at FreeBSD.org Mon Oct 13 20:07:14 2008 From: raj at FreeBSD.org (Rafal Jaworowski) Date: Mon Oct 13 20:07:26 2008 Subject: svn commit: r183840 - in head/sys: arm/arm arm/include arm/mv arm/mv/discovery arm/mv/kirkwood arm/mv/orion conf dev/uart Message-ID: <200810132007.m9DK7DwQ085091@svn.freebsd.org> Author: raj Date: Mon Oct 13 20:07:13 2008 New Revision: 183840 URL: http://svn.freebsd.org/changeset/base/183840 Log: Introduce basic support for Marvell families of system-on-chip ARM devices: * Orion - 88F5181 - 88F5182 - 88F5281 * Kirkwood - 88F6281 * Discovery - MV78100 The above families of SOCs are built around CPU cores compliant with ARMv5TE instruction set architecture definition. They share a number of integrated peripherals. This commit brings support for the following basic elements: * GPIO * Interrupt controller * L1, L2 cache * Timers, watchdog, RTC * TWSI (I2C) * UART Other peripherals drivers will be introduced separately. Reviewed by: imp, marcel, stass (Thanks guys!) Obtained from: Marvell, Semihalf Added: head/sys/arm/mv/ head/sys/arm/mv/bus_space.c (contents, props changed) head/sys/arm/mv/common.c (contents, props changed) head/sys/arm/mv/discovery/ head/sys/arm/mv/discovery/db78xxx.c (contents, props changed) head/sys/arm/mv/discovery/discovery.c (contents, props changed) head/sys/arm/mv/discovery/files.db78xxx (contents, props changed) head/sys/arm/mv/discovery/std.db78xxx (contents, props changed) head/sys/arm/mv/files.mv (contents, props changed) head/sys/arm/mv/gpio.c (contents, props changed) head/sys/arm/mv/ic.c (contents, props changed) head/sys/arm/mv/kirkwood/ head/sys/arm/mv/kirkwood/db88f6xxx.c (contents, props changed) head/sys/arm/mv/kirkwood/files.db88f6xxx (contents, props changed) head/sys/arm/mv/kirkwood/kirkwood.c (contents, props changed) head/sys/arm/mv/kirkwood/std.db88f6xxx (contents, props changed) head/sys/arm/mv/mv_machdep.c (contents, props changed) head/sys/arm/mv/mvreg.h (contents, props changed) head/sys/arm/mv/mvvar.h (contents, props changed) head/sys/arm/mv/obio.c (contents, props changed) head/sys/arm/mv/orion/ head/sys/arm/mv/orion/db88f5xxx.c (contents, props changed) head/sys/arm/mv/orion/files.db88f5xxx (contents, props changed) head/sys/arm/mv/orion/orion.c (contents, props changed) head/sys/arm/mv/orion/std.db88f5xxx (contents, props changed) head/sys/arm/mv/rtc.c (contents, props changed) head/sys/arm/mv/std.mv (contents, props changed) head/sys/arm/mv/timer.c (contents, props changed) head/sys/arm/mv/twsi.c (contents, props changed) head/sys/dev/uart/uart_bus_mbus.c (contents, props changed) head/sys/dev/uart/uart_cpu_mv.c (contents, props changed) Modified: head/sys/arm/arm/elf_trampoline.c head/sys/arm/include/intr.h head/sys/arm/include/resource.h head/sys/conf/Makefile.arm head/sys/conf/options.arm Modified: head/sys/arm/arm/elf_trampoline.c ============================================================================== --- head/sys/arm/arm/elf_trampoline.c Mon Oct 13 19:14:14 2008 (r183839) +++ head/sys/arm/arm/elf_trampoline.c Mon Oct 13 20:07:13 2008 (r183840) @@ -73,6 +73,8 @@ void __startC(void); #endif #ifdef CPU_XSCALE_81342 #define cpu_l2cache_wbinv_all xscalec3_l2cache_purge +#elif defined(SOC_MV_KIRKWOOD) || defined(SOC_MV_DISCOVERY) +#define cpu_l2cache_wbinv_all feroceon_l2cache_wbinv_all #else #define cpu_l2cache_wbinv_all() #endif Modified: head/sys/arm/include/intr.h ============================================================================== --- head/sys/arm/include/intr.h Mon Oct 13 19:14:14 2008 (r183839) +++ head/sys/arm/include/intr.h Mon Oct 13 20:07:13 2008 (r183840) @@ -44,7 +44,9 @@ #elif defined(CPU_XSCALE_PXA2X0) #include #define NIRQ IRQ_GPIO_MAX -#elif defined(CPU_ARM9) +#elif defined(SOC_MV_DISCOVERY) +#define NIRQ 96 +#elif defined(CPU_ARM9) || defined(SOC_MV_KIRKWOOD) #define NIRQ 64 #else #define NIRQ 32 Modified: head/sys/arm/include/resource.h ============================================================================== --- head/sys/arm/include/resource.h Mon Oct 13 19:14:14 2008 (r183839) +++ head/sys/arm/include/resource.h Mon Oct 13 20:07:13 2008 (r183840) @@ -41,5 +41,6 @@ #define SYS_RES_DRQ 2 /* isa dma lines */ #define SYS_RES_MEMORY 3 /* i/o memory */ #define SYS_RES_IOPORT 4 /* i/o ports */ +#define SYS_RES_GPIO 5 /* general purpose i/o */ #endif /* !_MACHINE_RESOURCE_H_ */ Added: head/sys/arm/mv/bus_space.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm/mv/bus_space.c Mon Oct 13 20:07:13 2008 (r183840) @@ -0,0 +1,162 @@ +/*- + * Copyright (C) 2008 MARVELL INTERNATIONAL LTD. + * All rights reserved. + * + * Developed by Semihalf. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of MARVELL nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include + +#include + +/* + * Bus space functions for Marvell SoC family + */ + +/* Prototypes for all the bus_space structure functions */ +bs_protos(generic); +bs_protos(generic_armv4); + +/* + * The obio bus space tag. This is constant for all instances, so + * we never have to explicitly "create" it. + */ +static struct bus_space _base_tag = { + /* cookie */ + (void *) 0, + + /* mapping/unmapping */ + generic_bs_map, + generic_bs_unmap, + generic_bs_subregion, + + /* allocation/deallocation */ + generic_bs_alloc, + generic_bs_free, + + /* barrier */ + generic_bs_barrier, + + /* read (single) */ + generic_bs_r_1, + generic_armv4_bs_r_2, + generic_bs_r_4, + NULL, + + /* read multiple */ + generic_bs_rm_1, + generic_armv4_bs_rm_2, + generic_bs_rm_4, + NULL, + + /* read region */ + generic_bs_rr_1, + generic_armv4_bs_rr_2, + generic_bs_rr_4, + NULL, + + /* write (single) */ + generic_bs_w_1, + generic_armv4_bs_w_2, + generic_bs_w_4, + NULL, + + /* write multiple */ + generic_bs_wm_1, + generic_armv4_bs_wm_2, + generic_bs_wm_4, + NULL, + + /* write region */ + NULL, + NULL, + NULL, + NULL, + + /* set multiple */ + NULL, + NULL, + NULL, + NULL, + + /* set region */ + NULL, + NULL, + NULL, + NULL, + + /* copy */ + NULL, + NULL, + NULL, + NULL, + + /* read stream (single) */ + NULL, + NULL, + NULL, + NULL, + + /* read multiple stream */ + NULL, + generic_armv4_bs_rm_2, /* bus_space_read_multi_stream_2 */ + NULL, + NULL, + + /* read region stream */ + NULL, + NULL, + NULL, + NULL, + + /* write stream (single) */ + NULL, + NULL, + NULL, + NULL, + + /* write multiple stream */ + NULL, + generic_armv4_bs_wm_2, /* bus_space_write_multi_stream_2 */ + NULL, + NULL, + + /* write region stream */ + NULL, + NULL, + NULL, + NULL +}; + +bus_space_tag_t obio_tag = &_base_tag; Added: head/sys/arm/mv/common.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/arm/mv/common.c Mon Oct 13 20:07:13 2008 (r183840) @@ -0,0 +1,965 @@ +/*- + * Copyright (C) 2008 MARVELL INTERNATIONAL LTD. + * All rights reserved. + * + * Developed by Semihalf. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of MARVELL nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#include + +#include +#include + +static int win_eth_can_remap(int i); + +static int decode_win_cpu_valid(void); +static int decode_win_usb_valid(void); +static int decode_win_eth_valid(void); +static int decode_win_pcie_valid(void); + +static void decode_win_cpu_setup(void); +static void decode_win_usb_setup(uint32_t ctrl); +static void decode_win_eth_setup(uint32_t base); +static void decode_win_pcie_setup(uint32_t base); + +static uint32_t dev, rev; + +uint32_t +read_cpu_ctrl(uint32_t reg) +{ + + return (bus_space_read_4(obio_tag, MV_CPU_CONTROL_BASE, reg)); +} + +void +write_cpu_ctrl(uint32_t reg, uint32_t val) +{ + + bus_space_write_4(obio_tag, MV_CPU_CONTROL_BASE, reg, val); +} + +void +cpu_reset(void) +{ + + write_cpu_ctrl(RSTOUTn_MASK, SOFT_RST_OUT_EN); + write_cpu_ctrl(SYSTEM_SOFT_RESET, SYS_SOFT_RST); + while (1); +} + +uint32_t +cpu_extra_feat(void) +{ + uint32_t ef = 0; + + soc_id(&dev, &rev); + if (dev == MV_DEV_88F6281 || dev == MV_DEV_MV78100) + __asm __volatile("mrc p15, 1, %0, c15, c1, 0" : "=r" (ef)); + else if (dev == MV_DEV_88F5182 || dev == MV_DEV_88F5281) + __asm __volatile("mrc p15, 0, %0, c14, c0, 0" : "=r" (ef)); + else if (bootverbose) + printf("This ARM Core does not support any extra features\n"); + + return (ef); +} + +uint32_t +soc_power_ctrl_get(uint32_t mask) +{ + + if (mask != CPU_PM_CTRL_NONE) + mask &= read_cpu_ctrl(CPU_PM_CTRL); + + return (mask); +} + +uint32_t +get_tclk(void) +{ + +#if defined(SOC_MV_DISCOVERY) + return (TCLK_200MHZ); +#else + return (TCLK_166MHZ); +#endif +} + +void +soc_id(uint32_t *dev, uint32_t *rev) +{ + + /* + * Notice: system identifiers are available in the registers range of + * PCIE controller, so using this function is only allowed (and + * possible) after the internal registers range has been mapped in via + * pmap_devmap_bootstrap(). + */ + *dev = bus_space_read_4(obio_tag, MV_PCIE_BASE, 0) >> 16; + *rev = bus_space_read_4(obio_tag, MV_PCIE_BASE, 8) & 0xff; +} + +void +soc_identify(void) +{ + uint32_t d, r; + const char *dev; + const char *rev; + + soc_id(&d, &r); + + printf("SOC: "); + if (bootverbose) + printf("(0x%4x:0x%02x) ", d, r); + + rev = ""; + switch (d) { + case MV_DEV_88F5181: + dev = "Marvell 88F5181"; + if (r == 3) + rev = "B1"; + break; + case MV_DEV_88F5182: + dev = "Marvell 88F5182"; + if (r == 2) + rev = "A2"; + break; + case MV_DEV_88F5281: + dev = "Marvell 88F5281"; + if (r == 4) + rev = "D0"; + else if (r == 5) + rev = "D1"; + else if (r == 6) + rev = "D2"; + break; + case MV_DEV_88F6281: + dev = "Marvell 88F6281"; + break; + case MV_DEV_MV78100: + dev = "Marvell MV78100"; + break; + default: + dev = "UNKNOWN"; + break; + } + + printf("%s", dev); + if (*rev != '\0') + printf(" rev %s", rev); + printf(", TClock %dMHz\n", get_tclk() / 1000 / 1000); + + /* TODO add info on currently set endianess */ +} + +int +soc_decode_win(void) +{ + + /* Retrieve our ID: some windows facilities vary between SoC models */ + soc_id(&dev, &rev); + + if (decode_win_cpu_valid() != 1 || decode_win_usb_valid() != 1 || + decode_win_eth_valid() != 1 || decode_win_idma_valid() != 1 || + decode_win_pcie_valid() != 1) + return(-1); + + decode_win_cpu_setup(); + decode_win_usb_setup(MV_USB0_BASE); + decode_win_eth_setup(MV_ETH0_BASE); + if (dev == MV_DEV_MV78100) + decode_win_eth_setup(MV_ETH1_BASE); + decode_win_idma_setup(); + decode_win_pcie_setup(MV_PCIE_BASE); + + /* TODO set up decode wins for SATA */ + + return (0); +} + +/************************************************************************** + * Decode windows registers accessors + **************************************************************************/ +WIN_REG_IDX_RD(win_cpu, cr, MV_WIN_CPU_CTRL, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_RD(win_cpu, br, MV_WIN_CPU_BASE, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_RD(win_cpu, remap_l, MV_WIN_CPU_REMAP_LO, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_RD(win_cpu, remap_h, MV_WIN_CPU_REMAP_HI, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_WR(win_cpu, cr, MV_WIN_CPU_CTRL, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_WR(win_cpu, br, MV_WIN_CPU_BASE, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_WR(win_cpu, remap_l, MV_WIN_CPU_REMAP_LO, MV_MBUS_BRIDGE_BASE) +WIN_REG_IDX_WR(win_cpu, remap_h, MV_WIN_CPU_REMAP_HI, MV_MBUS_BRIDGE_BASE) + +WIN_REG_IDX_RD(ddr, br, MV_WIN_DDR_BASE, MV_DDR_CADR_BASE) +WIN_REG_IDX_RD(ddr, sz, MV_WIN_DDR_SIZE, MV_DDR_CADR_BASE) + +WIN_REG_IDX_RD(win_usb, cr, MV_WIN_USB_CTRL, MV_USB_AWR_BASE) +WIN_REG_IDX_RD(win_usb, br, MV_WIN_USB_BASE, MV_USB_AWR_BASE) +WIN_REG_IDX_WR(win_usb, cr, MV_WIN_USB_CTRL, MV_USB_AWR_BASE) +WIN_REG_IDX_WR(win_usb, br, MV_WIN_USB_BASE, MV_USB_AWR_BASE) + +WIN_REG_BASE_IDX_RD(win_eth, br, MV_WIN_ETH_BASE) +WIN_REG_BASE_IDX_RD(win_eth, sz, MV_WIN_ETH_SIZE) +WIN_REG_BASE_IDX_RD(win_eth, har, MV_WIN_ETH_REMAP) +WIN_REG_BASE_IDX_WR(win_eth, br, MV_WIN_ETH_BASE) +WIN_REG_BASE_IDX_WR(win_eth, sz, MV_WIN_ETH_SIZE) +WIN_REG_BASE_IDX_WR(win_eth, har, MV_WIN_ETH_REMAP) +WIN_REG_BASE_RD(win_eth, bare, 0x290) +WIN_REG_BASE_RD(win_eth, epap, 0x294) +WIN_REG_BASE_WR(win_eth, bare, 0x290) +WIN_REG_BASE_WR(win_eth, epap, 0x294) + +WIN_REG_BASE_IDX_RD(win_pcie, cr, MV_WIN_PCIE_CTRL); +WIN_REG_BASE_IDX_RD(win_pcie, br, MV_WIN_PCIE_BASE); +WIN_REG_BASE_IDX_RD(win_pcie, remap, MV_WIN_PCIE_REMAP); +WIN_REG_BASE_IDX_WR(win_pcie, cr, MV_WIN_PCIE_CTRL); +WIN_REG_BASE_IDX_WR(win_pcie, br, MV_WIN_PCIE_BASE); +WIN_REG_BASE_IDX_WR(win_pcie, remap, MV_WIN_PCIE_REMAP); +WIN_REG_BASE_IDX_WR(pcie, bar, MV_PCIE_BAR); + +WIN_REG_IDX_RD(win_idma, br, MV_WIN_IDMA_BASE, MV_IDMA_BASE) +WIN_REG_IDX_RD(win_idma, sz, MV_WIN_IDMA_SIZE, MV_IDMA_BASE) +WIN_REG_IDX_RD(win_idma, har, MV_WIN_IDMA_REMAP, MV_IDMA_BASE) +WIN_REG_IDX_RD(win_idma, cap, MV_WIN_IDMA_CAP, MV_IDMA_BASE) +WIN_REG_IDX_WR(win_idma, br, MV_WIN_IDMA_BASE, MV_IDMA_BASE) +WIN_REG_IDX_WR(win_idma, sz, MV_WIN_IDMA_SIZE, MV_IDMA_BASE) +WIN_REG_IDX_WR(win_idma, har, MV_WIN_IDMA_REMAP, MV_IDMA_BASE) +WIN_REG_IDX_WR(win_idma, cap, MV_WIN_IDMA_CAP, MV_IDMA_BASE) +WIN_REG_RD(win_idma, bare, 0xa80, MV_IDMA_BASE) +WIN_REG_WR(win_idma, bare, 0xa80, MV_IDMA_BASE) + +/************************************************************************** + * Decode windows helper routines + **************************************************************************/ +void +soc_dump_decode_win(void) +{ + int i; + + soc_id(&dev, &rev); + + for (i = 0; i < MV_WIN_CPU_MAX; i++) { + printf("CPU window#%d: c 0x%08x, b 0x%08x", i, + win_cpu_cr_read(i), + win_cpu_br_read(i)); + + if (win_cpu_can_remap(i)) + printf(", rl 0x%08x, rh 0x%08x", + win_cpu_remap_l_read(i), + win_cpu_remap_h_read(i)); + + printf("\n"); + } + printf("Internal regs base: 0x%08x\n", + bus_space_read_4(obio_tag, MV_INTREGS_BASE, 0)); + + for (i = 0; i < MV_WIN_DDR_MAX; i++) + printf("DDR CS#%d: b 0x%08x, s 0x%08x\n", i, + ddr_br_read(i), ddr_sz_read(i)); + + for (i = 0; i < MV_WIN_USB_MAX; i++) + printf("USB window#%d: c 0x%08x, b 0x%08x\n", i, + win_usb_cr_read(i), win_usb_br_read(i)); + + for (i = 0; i < MV_WIN_ETH_MAX; i++) { + printf("ETH window#%d: b 0x%08x, s 0x%08x", i, + win_eth_br_read(MV_ETH0_BASE, i), + win_eth_sz_read(MV_ETH0_BASE, i)); + + if (win_eth_can_remap(i)) + printf(", ha 0x%08x", + win_eth_har_read(MV_ETH0_BASE, i)); + + printf("\n"); + } + printf("ETH windows: bare 0x%08x, epap 0x%08x\n", + win_eth_bare_read(MV_ETH0_BASE), + win_eth_epap_read(MV_ETH0_BASE)); + + decode_win_idma_dump(); + printf("\n"); +} + +/************************************************************************** + * CPU windows routines + **************************************************************************/ +int +win_cpu_can_remap(int i) +{ + + /* Depending on the SoC certain windows have remap capability */ + if ((dev == MV_DEV_88F5182 && i < 2) || + (dev == MV_DEV_88F5281 && i < 4) || + (dev == MV_DEV_88F6281 && i < 4) || + (dev == MV_DEV_MV78100 && i < 8)) + return (1); + + return (0); +} + +/* XXX This should check for overlapping remap fields too.. */ +int +decode_win_overlap(int win, int win_no, const struct decode_win *wintab) +{ + const struct decode_win *tab; + int i; + + tab = wintab; + + for (i = 0; i < win_no; i++, tab++) { + if (i == win) + /* Skip self */ + continue; + + if ((tab->base + tab->size - 1) < (wintab + win)->base) + continue; + + else if (((wintab + win)->base + (wintab + win)->size - 1) < + tab->base) + continue; + else + return (i); + } + + return (-1); +} + +static int +decode_win_cpu_valid(void) +{ + int i, j, rv; + uint32_t b, e, s; + + if (cpu_wins_no > MV_WIN_CPU_MAX) { + printf("CPU windows: too many entries: %d\n", cpu_wins_no); + return (-1); + } + + rv = 1; + for (i = 0; i < cpu_wins_no; i++) { + + if (cpu_wins[i].target == 0) { + printf("CPU window#%d: DDR target window is not " + "supposed to be reprogrammed!\n", i); + rv = 0; + } + + if (cpu_wins[i].remap >= 0 && win_cpu_can_remap(i) != 1) { + printf("CPU window#%d: not capable of remapping, but " + "val 0x%08x defined\n", i, cpu_wins[i].remap); + rv = 0; + } + + s = cpu_wins[i].size; + b = cpu_wins[i].base; + e = b + s - 1; + if (s > (0xFFFFFFFF - b + 1)) { + /* + * XXX this boundary check should account for 64bit + * and remapping.. + */ + printf("CPU window#%d: no space for size 0x%08x at " + "0x%08x\n", i, s, b); + rv = 0; + continue; + } + + j = decode_win_overlap(i, cpu_wins_no, &cpu_wins[0]); + if (j >= 0) { + printf("CPU window#%d: (0x%08x - 0x%08x) overlaps " + "with #%d (0x%08x - 0x%08x)\n", i, b, e, j, + cpu_wins[j].base, + cpu_wins[j].base + cpu_wins[j].size - 1); + rv = 0; + } + } + + return (rv); +} + +static void +decode_win_cpu_setup(void) +{ + uint32_t br, cr; + int i; + + /* Disable all CPU windows */ + for (i = 0; i < MV_WIN_CPU_MAX; i++) { + win_cpu_cr_write(i, 0); + win_cpu_br_write(i, 0); + if (win_cpu_can_remap(i)) { + win_cpu_remap_l_write(i, 0); + win_cpu_remap_h_write(i, 0); + } + } + + for (i = 0; i < cpu_wins_no; i++) + if (cpu_wins[i].target > 0) { + + br = cpu_wins[i].base & 0xffff0000; + win_cpu_br_write(i, br); + + if (win_cpu_can_remap(i)) { + if (cpu_wins[i].remap >= 0) { + win_cpu_remap_l_write(i, + cpu_wins[i].remap & 0xffff0000); + win_cpu_remap_h_write(i, 0); + } else { + /* + * Remap function is not used for + * a given window (capable of + * remapping) - set remap field with the + * same value as base. + */ + win_cpu_remap_l_write(i, + cpu_wins[i].base & 0xffff0000); + win_cpu_remap_h_write(i, 0); + } + } + + cr = ((cpu_wins[i].size - 1) & 0xffff0000) | + (cpu_wins[i].attr << 8) | + (cpu_wins[i].target << 4) | 1; + + win_cpu_cr_write(i, cr); + } +} + +/* + * Check if we're able to cover all active DDR banks. + */ +static int +decode_win_can_cover_ddr(int max) +{ + int i, c; + + c = 0; + for (i = 0; i < MV_WIN_DDR_MAX; i++) + if (ddr_is_active(i)) + c++; + + if (c > max) { + printf("Unable to cover all active DDR banks: " + "%d, available windows: %d\n", c, max); + return (0); + } + + return (1); +} + +/************************************************************************** + * DDR windows routines + **************************************************************************/ +int +ddr_is_active(int i) +{ + + if (ddr_sz_read(i) & 0x1) + return (1); + + return (0); +} + +uint32_t +ddr_base(int i) +{ + + return (ddr_br_read(i) & 0xff000000); +} + +uint32_t +ddr_size(int i) +{ + + return ((ddr_sz_read(i) | 0x00ffffff) + 1); +} + +uint32_t +ddr_attr(int i) +{ + + return (i == 0 ? 0xe : + (i == 1 ? 0xd : + (i == 2 ? 0xb : + (i == 3 ? 0x7 : 0xff)))); +} + +uint32_t +ddr_target(int i) +{ + + /* Mbus unit ID is 0x0 for DDR SDRAM controller */ + return (0); +} + +/************************************************************************** + * USB windows routines + **************************************************************************/ +static int +decode_win_usb_valid(void) +{ + + return (decode_win_can_cover_ddr(MV_WIN_USB_MAX)); +} + +/* + * Set USB decode windows. + */ +static void +decode_win_usb_setup(uint32_t ctrl) +{ + uint32_t br, cr; + int i, j; + + /* Disable and clear all USB windows */ + for (i = 0; i < MV_WIN_USB_MAX; i++) { + win_usb_cr_write(i, 0); + win_usb_br_write(i, 0); + } + + /* Only access to active DRAM banks is required */ + for (i = 0; i < MV_WIN_DDR_MAX; i++) + if (ddr_is_active(i)) { + br = ddr_base(i); + /* + * XXX for 6281 we should handle Mbus write burst limit + * field in the ctrl reg + */ + cr = (((ddr_size(i) - 1) & 0xffff0000) | + (ddr_attr(i) << 8) | (ddr_target(i) << 4) | 1); + + /* Set the first free USB window */ + for (j = 0; j < MV_WIN_USB_MAX; j++) { + if (win_usb_cr_read(j) & 0x1) + continue; + + win_usb_br_write(j, br); + win_usb_cr_write(j, cr); + break; + } + } +} + +/************************************************************************** + * ETH windows routines + **************************************************************************/ + +static int +win_eth_can_remap(int i) +{ + + /* ETH encode windows 0-3 have remap capability */ + if (i < 4) + return (1); + + return (0); +} + +static int +eth_bare_read(uint32_t base, int i) +{ + uint32_t v; + + v = win_eth_bare_read(base); + v &= (1 << i); + + return (v >> i); +} + +static void +eth_bare_write(uint32_t base, int i, int val) +{ + uint32_t v; + + v = win_eth_bare_read(base); + v &= ~(1 << i); + v |= (val << i); + win_eth_bare_write(base, v); +} + +static void +eth_epap_write(uint32_t base, int i, int val) +{ + uint32_t v; + + v = win_eth_epap_read(base); + v &= ~(0x3 << (i * 2)); + v |= (val << (i * 2)); + win_eth_epap_write(base, v); +} + +static void +decode_win_eth_setup(uint32_t base) +{ + uint32_t br, sz; + int i, j; + + /* Disable, clear and revoke protection for all ETH windows */ + for (i = 0; i < MV_WIN_ETH_MAX; i++) { + + eth_bare_write(base, i, 1); + eth_epap_write(base, i, 0); + win_eth_br_write(base, i, 0); + win_eth_sz_write(base, i, 0); + if (win_eth_can_remap(i)) + win_eth_har_write(base, i, 0); + } + + /* Only access to active DRAM banks is required */ + for (i = 0; i < MV_WIN_DDR_MAX; i++) + if (ddr_is_active(i)) { + + br = ddr_base(i) | (ddr_attr(i) << 8) | ddr_target(i); + sz = ((ddr_size(i) - 1) & 0xffff0000); + + /* Set the first free ETH window */ + for (j = 0; j < MV_WIN_ETH_MAX; j++) { + if (eth_bare_read(base, j) == 0) + continue; + + win_eth_br_write(base, j, br); + win_eth_sz_write(base, j, sz); + + /* XXX remapping ETH windows not supported */ + + /* Set protection RW */ + eth_epap_write(base, j, 0x3); + + /* Enable window */ + eth_bare_write(base, j, 0); + break; + } + } +} + +static int +decode_win_eth_valid(void) +{ + + return (decode_win_can_cover_ddr(MV_WIN_ETH_MAX)); +} + +/************************************************************************** + * PCIE windows routines + **************************************************************************/ + +static void +decode_win_pcie_setup(uint32_t base) +{ + uint32_t size = 0; + uint32_t cr, br; + int i, j; + + for (i = 0; i < MV_PCIE_BAR_MAX; i++) + pcie_bar_write(base, i, 0); + + for (i = 0; i < MV_WIN_PCIE_MAX; i++) { + win_pcie_cr_write(base, i, 0); + win_pcie_br_write(base, i, 0); + win_pcie_remap_write(base, i, 0); + } + + for (i = 0; i < MV_WIN_DDR_MAX; i++) { + if (ddr_is_active(i)) { + /* Map DDR to BAR 1 */ + cr = (ddr_size(i) - 1) & 0xffff0000; + size += ddr_size(i) & 0xffff0000; + cr |= (ddr_attr(i) << 8) | (ddr_target(i) << 4) | 1; + br = ddr_base(i); + + /* Use the first available PCIE window */ + for (j = 0; j < MV_WIN_PCIE_MAX; j++) { + if (win_pcie_cr_read(base, j) != 0) + continue; + + win_pcie_br_write(base, j, br); + win_pcie_cr_write(base, j, cr); + break; + } + } + } + + /* + * Upper 16 bits in BAR register is interpreted as BAR size + * (in 64 kB units) plus 64kB, so substract 0x10000 + * form value passed to register to get correct value. + */ + size -= 0x10000; + pcie_bar_write(base, 0, size | 1); +} + +static int +decode_win_pcie_valid(void) +{ + + return (decode_win_can_cover_ddr(MV_WIN_PCIE_MAX)); +} + +/************************************************************************** + * IDMA windows routines + **************************************************************************/ +#if defined(SOC_MV_ORION) || defined(SOC_MV_DISCOVERY) +static int +idma_bare_read(int i) +{ + uint32_t v; + + v = win_idma_bare_read(); + v &= (1 << i); + + return (v >> i); +} + +static void +idma_bare_write(int i, int val) +{ + uint32_t v; + + v = win_idma_bare_read(); + v &= ~(1 << i); + v |= (val << i); + win_idma_bare_write(v); +} + +/* + * Sets channel protection 'val' for window 'w' on channel 'c' + */ +static void +idma_cap_write(int c, int w, int val) +{ + uint32_t v; + + v = win_idma_cap_read(c); + v &= ~(0x3 << (w * 2)); + v |= (val << (w * 2)); + win_idma_cap_write(c, v); +} + +/* + * Set protection 'val' on all channels for window 'w' + */ +static void +idma_set_prot(int w, int val) +{ + int c; + + for (c = 0; c < MV_IDMA_CHAN_MAX; c++) + idma_cap_write(c, w, val); +} + +static int +win_idma_can_remap(int i) +{ + + /* IDMA decode windows 0-3 have remap capability */ + if (i < 4) + return (1); + + return (0); +} + +void +decode_win_idma_setup(void) +{ + uint32_t br, sz; + int i, j; + + /* + * Disable and clear all IDMA windows, revoke protection for all channels + */ + for (i = 0; i < MV_WIN_IDMA_MAX; i++) { + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From imp at FreeBSD.org Mon Oct 13 20:24:04 2008 From: imp at FreeBSD.org (Warner Losh) Date: Mon Oct 13 20:24:16 2008 Subject: svn commit: r183841 - head/libexec/rtld-elf/mips Message-ID: <200810132024.m9DKO4eO085447@svn.freebsd.org> Author: imp Date: Mon Oct 13 20:24:03 2008 New Revision: 183841 URL: http://svn.freebsd.org/changeset/base/183841 Log: This code has no copyright. It is fairly obvious to me that we're a derivitive of NetBSD's mips_reloc.c, so pull in the copyright notice from there. Also, a minor tweak to load/store pointers. Other changes from NetBSD likely would be useful too... Obtained from: NetBSD Modified: head/libexec/rtld-elf/mips/reloc.c Modified: head/libexec/rtld-elf/mips/reloc.c ============================================================================== --- head/libexec/rtld-elf/mips/reloc.c Mon Oct 13 20:07:13 2008 (r183840) +++ head/libexec/rtld-elf/mips/reloc.c Mon Oct 13 20:24:03 2008 (r183841) @@ -1,4 +1,33 @@ /* $NetBSD: mdreloc.c,v 1.23 2003/07/26 15:04:38 mrg Exp $ */ +/* $NetBSD: mips_reloc.c,v 1.53 2008/07/24 04:39:25 matt Exp $ */ + +/* + * Copyright 1997 Michael L. Hitch + * Portions copyright 2002 Charles M. Hannum + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include __FBSDID("$FreeBSD$"); @@ -35,21 +64,33 @@ void _rtld_relocate_nonplt_self(Elf_Dyn int open(); int _open(); +/* + * It is possible for the compiler to emit relocations for unaligned data. + * We handle this situation with these inlines. + */ +#define RELOC_ALIGNED_P(x) \ + (((uintptr_t)(x) & (sizeof(void *) - 1)) == 0) + static __inline Elf_Addr load_ptr(void *where) { - Elf_Addr res; - - memcpy(&res, where, sizeof(res)); + if (__predict_true(RELOC_ALIGNED_P(where))) + return *(Elf_Addr *)where; + else { + Elf_Addr res; - return (res); + (void)memcpy(&res, where, sizeof(res)); + return res; + } } -void +static __inline void store_ptr(void *where, Elf_Addr val) { - - memcpy(where, &val, sizeof(val)); + if (__predict_true(RELOC_ALIGNED_P(where))) + *(Elf_Addr *)where = val; + else + (void)memcpy(where, &val, sizeof(val)); } void @@ -149,13 +190,6 @@ _mips_rtld_bind(Obj_Entry *obj, Elf_Size } /* - * It is possible for the compiler to emit relocations for unaligned data. - * We handle this situation with these inlines. - */ -#define RELOC_ALIGNED_P(x) \ - (((uintptr_t)(x) & (sizeof(void *) - 1)) == 0) - -/* * Process non-PLT relocations */ int From n_hibma at FreeBSD.org Mon Oct 13 20:38:33 2008 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Mon Oct 13 20:38:39 2008 Subject: svn commit: r183842 - head/sys/dev/usb Message-ID: <200810132038.m9DKcXT2085748@svn.freebsd.org> Author: n_hibma Date: Mon Oct 13 20:38:33 2008 New Revision: 183842 URL: http://svn.freebsd.org/changeset/base/183842 Log: - Only refuse to attach to the first interface on the Huawei cards as for example the Huawei Mobile has an SD card slot on the second interface. - Do not attach to Qualcomm and Novatel cards. If ignored these cards will switch to modem mode automatically it seems. - Reduce the priority on generic attachment to the appropriate level. Note: A better solution is to send an eject command straightaway, but that can be left till later. Modified: head/sys/dev/usb/umass.c Modified: head/sys/dev/usb/umass.c ============================================================================== --- head/sys/dev/usb/umass.c Mon Oct 13 20:24:03 2008 (r183841) +++ head/sys/dev/usb/umass.c Mon Oct 13 20:38:33 2008 (r183842) @@ -1177,12 +1177,28 @@ umass_match_proto(struct umass_softc *sc dd = usbd_get_device_descriptor(udev); - /* - * These are radio devices with auto-install flash disks for win/mac. - * We want the ubsa driver to kick them into shape instead. - */ - if (UGETW(dd->idVendor) == USB_VENDOR_HUAWEI) - return(UMATCH_NONE); + /* These are 3G modes (E220, Mobile, etc.) devices with auto-install + * flash disks for Windows/MacOSX through the first interface. + * We are assuming that these vendors will not produce mass storage + * devices. See the list of supported parts in u3g, if this happens to + * be a mistake in the future. + */ + if (UGETW(dd->idVendor) == USB_VENDOR_HUAWEI) { + /* The interface is reset in the u3g driver + * (u3g_huawei_reinit()). Allow generic attachment to the + * second interface though. Some Huawei devices contain an SD + * card slot. + */ + id = usbd_get_interface_descriptor(iface); + if (id == NULL || id->bInterfaceNumber == 0) + return UMATCH_NONE; + } else if (UGETW(dd->idVendor) == USB_VENDOR_QUALCOMMINC + || UGETW(dd->idVendor) == USB_VENDOR_NOVATEL) { + /* Device by these vendors will automatically reappear as a + * ucom device if ignored (or if sent an eject command). + */ + return UMATCH_NONE; + } /* An entry specifically for Y-E Data devices as they don't fit in the * device description table. @@ -1279,7 +1295,7 @@ umass_match_proto(struct umass_softc *sc return(UMATCH_NONE); } - return(UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO); + return(UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO); } static int @@ -1291,6 +1307,7 @@ umass_match(device_t self) sc->sc_dev = self; if (uaa->iface == NULL) return(UMATCH_NONE); + return(umass_match_proto(sc, uaa->iface, uaa->device)); } From n_hibma at FreeBSD.org Mon Oct 13 20:41:11 2008 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Mon Oct 13 20:41:24 2008 Subject: svn commit: r183843 - head/sys/dev/usb Message-ID: <200810132041.m9DKfBVx085825@svn.freebsd.org> Author: n_hibma Date: Mon Oct 13 20:41:11 2008 New Revision: 183843 URL: http://svn.freebsd.org/changeset/base/183843 Log: - Add better support for Huawei cards, by attaching as an interface driver. - Be bold and add Novatel cards to the list of supported devices. One person reported success with the Novatal U950D. Modified: head/sys/dev/usb/u3g.c head/sys/dev/usb/ubsa.c Modified: head/sys/dev/usb/u3g.c ============================================================================== --- head/sys/dev/usb/u3g.c Mon Oct 13 20:38:33 2008 (r183842) +++ head/sys/dev/usb/u3g.c Mon Oct 13 20:41:11 2008 (r183843) @@ -1,8 +1,8 @@ /* * Copyright (c) 2008 AnyWi Technologies - * Author: Andrea Guzzo - * * based on uark.c 1.1 2006/08/14 08:30:22 jsg * - * * parts from ubsa.c 183348 2008-09-25 12:00:56Z phk * + * Author: Andrea Guzzo + * * based on uark.c 1.1 2006/08/14 08:30:22 jsg * + * * parts from ubsa.c 183348 2008-09-25 12:00:56Z phk * * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -41,31 +41,33 @@ #include "usbdevs.h" #ifdef U3G_DEBUG -#define DPRINTFN(n, x) do { if (u3gdebug > (n)) printf x; } while (0) -int u3gtebug = 0; +#define DPRINTFN(n, x) do { if (u3gdebug > (n)) printf x; } while (0) +int u3gtebug = 0; #else #define DPRINTFN(n, x) #endif #define DPRINTF(x) DPRINTFN(0, x) -#define U3GBUFSZ 1024 -#define U3G_MAXPORTS 4 +#define U3G_BUFSIZ 1024 +#define U3G_MAXPORTS 4 +#define U3G_CONFIG_INDEX 0 struct u3g_softc { - struct ucom_softc sc_ucom[U3G_MAXPORTS];; - device_t sc_dev; - usbd_device_handle sc_udev; - u_char sc_msr; - u_char sc_lsr; - u_char numports; + struct ucom_softc sc_ucom[U3G_MAXPORTS];; + device_t sc_dev; + usbd_device_handle sc_udev; + u_int16_t sc_flags; + u_char sc_msr; + u_char sc_lsr; + u_char numports; - usbd_interface_handle sc_intr_iface; /* interrupt interface */ + usbd_interface_handle sc_intr_iface; /* interrupt interface */ #ifdef U3G_DEBUG - int sc_intr_number; /* interrupt number */ - usbd_pipe_handle sc_intr_pipe; /* interrupt pipe */ - u_char *sc_intr_buf; /* interrupt buffer */ + int sc_intr_number; /* interrupt number */ + usbd_pipe_handle sc_intr_pipe; /* interrupt pipe */ + u_char *sc_intr_buf; /* interrupt buffer */ #endif - int sc_isize; + int sc_isize; }; struct ucom_callback u3g_callback = { @@ -79,49 +81,79 @@ struct ucom_callback u3g_callback = { NULL, }; -static const struct usb_devno u3g_devs[] = { + +/* + * Various supported device vendors/products. + */ +struct u3g_dev_type_s { + struct usb_devno u3g_dev; + u_int16_t u3g_flags; +#define U3GFL_NONE 0x0000 +#define U3GFL_HUAWEI_INIT 0x0001 /* Send USB command to reset iface to ucom mode */ +#define U3GFL_EJECT 0x0002 /* Send SCSI eject to reset first iface to ucom mode */ +}; + +static const struct u3g_dev_type_s u3g_devs[] = { /* OEM: Option */ - { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3G }, - { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GQUAD }, - { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GPLUS }, - { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GTMAX36 }, - { USB_VENDOR_OPTION, USB_PRODUCT_OPTION_VODAFONEMC3G }, + {{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3G }, U3GFL_NONE}, + {{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GQUAD }, U3GFL_NONE}, + {{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GPLUS }, U3GFL_NONE}, + {{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GTMAX36 }, U3GFL_NONE}, + {{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_VODAFONEMC3G }, U3GFL_NONE}, + /* OEM: Qualcomm, Inc. */ + {{ USB_VENDOR_QUALCOMMINC, USB_PRODUCT_QUALCOMMINC_CDMA_MSM }, U3GFL_EJECT}, /* OEM: Huawei */ - { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_MOBILE }, - { USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220 }, - /* OEM: Qualcomm */ - { USB_VENDOR_QUALCOMMINC, USB_PRODUCT_QUALCOMMINC_CDMA_MSM }, - - { 0, 0 } + {{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_MOBILE }, U3GFL_HUAWEI_INIT}, + {{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220 }, U3GFL_HUAWEI_INIT}, + /* OEM: Novatel */ + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_CDMA_MODEM }, U3GFL_NONE }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_ES620 }, U3GFL_NONE }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U720 }, U3GFL_NONE }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U727 }, U3GFL_NONE }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740 }, U3GFL_NONE }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740_2 }, U3GFL_NONE }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U950D }, U3GFL_EJECT }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V620 }, U3GFL_NONE }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V640 }, U3GFL_NONE }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V720 }, U3GFL_NONE }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V740 }, U3GFL_NONE }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_X950D }, U3GFL_NONE }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U870 }, U3GFL_NONE }, + {{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_XU870 }, U3GFL_NONE }, + {{ USB_VENDOR_DELL, USB_PRODUCT_DELL_U740 }, U3GFL_NONE }, }; +#define u3g_lookup(v, p) ((const struct u3g_dev_type_s *)usb_lookup(u3g_devs, v, p)) #ifdef U3G_DEBUG static void u3g_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status) { struct u3g_softc *sc = (struct u3g_softc *)priv; - device_printf(sc->sc_dev, "INTERRUPT CALLBACK\n"); + device_printf(sc->sc_dev, "Interrupt callback\n"); } #endif static int -u3g_huawei_reinit(usbd_device_handle dev) +u3g_huawei_reinit(usbd_device_handle dev, usbd_interface_handle iface) { /* The Huawei device presents itself as a umass device with Windows * drivers on it. After installation of the driver, it reinits into a * 3G serial device. */ usb_device_request_t req; - usb_config_descriptor_t *cdesc; + usb_interface_descriptor_t *idesc; - /* Get the config descriptor */ - cdesc = usbd_get_config_descriptor(dev); - if (cdesc == NULL) - return (UMATCH_NONE); + if (iface == NULL) + return UMATCH_NONE; + idesc = usbd_get_interface_descriptor(iface); + if (idesc == NULL) + return UMATCH_NONE; - /* One iface means umass mode, more than 1 (4 usually) means 3G mode */ - if (cdesc->bNumInterface > 1) - return (UMATCH_VENDOR_PRODUCT); + /* If the interface class is no longer mass storage it has changed + * appearance and we should attach it. + */ + if (idesc->bInterfaceClass == UICLASS_VENDOR) + return (UMATCH_VENDOR_PRODUCT_CONF_IFACE); req.bmRequestType = UT_WRITE_DEVICE; req.bRequest = UR_SET_FEATURE; @@ -139,15 +171,14 @@ u3g_match(device_t self) { struct usb_attach_arg *uaa = device_get_ivars(self); - if (uaa->iface != NULL) - return (UMATCH_NONE); - - if (uaa->vendor == USB_VENDOR_HUAWEI) - return u3g_huawei_reinit(uaa->device); + const struct u3g_dev_type_s *u3g_dev_type = u3g_lookup(uaa->vendor, uaa->product); + if (u3g_dev_type) { + if (u3g_dev_type->u3g_flags & U3GFL_HUAWEI_INIT) + return u3g_huawei_reinit(uaa->device, uaa->iface); + else + return UMATCH_VENDOR_PRODUCT; + } - if (usb_lookup(u3g_devs, uaa->vendor, uaa->product)) - return UMATCH_VENDOR_PRODUCT; - return UMATCH_NONE; } @@ -172,7 +203,7 @@ u3g_attach(device_t self) sc->sc_intr_pipe = NULL; #endif /* Move the device into the configured state. */ - error = usbd_set_config_index(dev, 1, 1); + error = usbd_set_config_index(dev, U3G_CONFIG_INDEX, 1); if (error) { device_printf(self, "failed to set configuration: %s\n", usbd_errstr(error)); @@ -210,14 +241,14 @@ u3g_attach(device_t self) ed = usbd_interface2endpoint_descriptor(iface, n); if (ed == NULL) { device_printf(ucom->sc_dev, - "could not read endpoint descriptor\n"); + "could not read endpoint descriptor\n"); goto bad; } - if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN && - UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) + if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN + && UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) ucom->sc_bulkin_no = ed->bEndpointAddress; - else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT && - UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) + else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT + && UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) ucom->sc_bulkout_no = ed->bEndpointAddress; } if (ucom->sc_bulkin_no == -1 || ucom->sc_bulkout_no == -1) { @@ -225,9 +256,9 @@ u3g_attach(device_t self) goto bad; } ucom->sc_parent = sc; - ucom->sc_ibufsize = U3GBUFSZ; - ucom->sc_obufsize = U3GBUFSZ; - ucom->sc_ibufsizepad = U3GBUFSZ; + ucom->sc_ibufsize = U3G_BUFSIZ; + ucom->sc_obufsize = U3G_BUFSIZ; + ucom->sc_ibufsizepad = U3G_BUFSIZ; ucom->sc_opkthdrlen = 0; ucom->sc_callback = &u3g_callback; @@ -254,14 +285,14 @@ u3g_attach(device_t self) u3g_intr, 100); if (error) { - device_printf(self, - "cannot open interrupt pipe (addr %d)\n", - sc->sc_intr_number); - goto bad; + device_printf(self, + "cannot open interrupt pipe (addr %d)\n", + sc->sc_intr_number); + goto bad; } } #endif - device_printf(self, "configured %d serial ports (/dev/cuaU%d.X)", + device_printf(self, "configured %d serial ports (/dev/cuaU%d.X)\n", sc->numports, device_get_unit(self)); return 0; @@ -286,7 +317,7 @@ u3g_detach(device_t self) sc->sc_ucom[i].sc_dying = 1; rv = ucom_detach(&sc->sc_ucom[i]); if(rv != 0) { - device_printf(self, "Can't deallocat port %d", i); + device_printf(self, "Can't deallocat port %d\n", i); return rv; } } @@ -302,8 +333,8 @@ u3g_detach(device_t self) err = usbd_close_pipe(sc->sc_intr_pipe); if (err) device_printf(self, - "close interrupt pipe failed: %s\n", - usbd_errstr(err)); + "close interrupt pipe failed: %s\n", + usbd_errstr(err)); free(sc->sc_intr_buf, M_USBDEV); sc->sc_intr_pipe = NULL; } Modified: head/sys/dev/usb/ubsa.c ============================================================================== --- head/sys/dev/usb/ubsa.c Mon Oct 13 20:38:33 2008 (r183842) +++ head/sys/dev/usb/ubsa.c Mon Oct 13 20:41:11 2008 (r183843) @@ -228,34 +228,6 @@ static const struct ubsa_product { { USB_VENDOR_PERACOM, USB_PRODUCT_PERACOM_SERIAL1 }, /* Merlin */ { USB_VENDOR_MERLIN, USB_PRODUCT_MERLIN_V620 }, - /* Novatel */ - { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_CDMA_MODEM }, - /* Novatel Wireless Merlin ES620 */ - { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_ES620 }, - /* Novatel Wireless Merlin U720 */ - { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U720 }, - /* Novatel Wireless Merlin U727 */ - { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U727 }, - /* Novatel Wireless Merlin U740 */ - { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740 }, - { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740_2 }, - /* Dell version of the Novatel 740 */ - { USB_VENDOR_DELL, USB_PRODUCT_DELL_U740 }, - /* Novatel Wireless Merlin U950D */ - { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U950D }, - /* Novatel Wireless Merlin V620 */ - { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V620 }, - /* Novatel Wireless Merlin V640 */ - { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V640 }, - /* Novatel Wireless Merlin V720 */ - { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V720 }, - /* Novatel Wireless Merlin V740 */ - { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V740 }, - /* Novatel Wireless Merlin X950D */ - { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_X950D }, - /* Novatel Wireless Merlin U870 */ - { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U870 }, - { USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_XU870 }, /* Sierra Wireless AirCard 580 */ { USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AIRCARD580 }, /* Sierra Wireless AirCard 595 */ From n_hibma at FreeBSD.org Mon Oct 13 20:43:09 2008 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Mon Oct 13 20:43:20 2008 Subject: svn commit: r183844 - head/share/man/man4 Message-ID: <200810132043.m9DKh8VN085896@svn.freebsd.org> Author: n_hibma Date: Mon Oct 13 20:43:08 2008 New Revision: 183844 URL: http://svn.freebsd.org/changeset/base/183844 Log: Update the man pages with the moved/added support for devices. The SD card slot of the Huawei mobile card is supported by the (generic) umass driver. Modified: head/share/man/man4/u3g.4 head/share/man/man4/ubsa.4 head/share/man/man4/umass.4 Modified: head/share/man/man4/u3g.4 ============================================================================== --- head/share/man/man4/u3g.4 Mon Oct 13 20:41:11 2008 (r183843) +++ head/share/man/man4/u3g.4 Mon Oct 13 20:43:08 2008 (r183844) @@ -66,10 +66,16 @@ Option Globetrotter 3G .It Vodafone Mobile Connect Card 3G .It +Qualcomm Inc. CDMA MSM +.It Huawei E220 (E270?) .It Huawei Mobile +.It +Novatal U950D .El +(See /sys/dev/u3g.c for the complete list of supported cards for each vendor +mentioned above). .Pp The supported 3G cards provide the necessary modem port for ppp, pppd, or mpd connections as well as extra ports (depending on the specific @@ -78,18 +84,13 @@ device) to provide other functions (diag .Xr tty 4 , .Xr ucom 4 , .Xr usb 4 , -.Xr ubsa 4 .Sh HISTORY The .Nm driver appeared in -.Fx 8.0 . -The -.Xr ubsa 4 -manual page was modified for -.Nm -by +.Fx 8.0 , +is based on the uark driver, and written by .An Andrea Guzzo Aq aguzzo@anywi.com in September 2008. .Sh AUTHORS Modified: head/share/man/man4/ubsa.4 ============================================================================== --- head/share/man/man4/ubsa.4 Mon Oct 13 20:41:11 2008 (r183843) +++ head/share/man/man4/ubsa.4 Mon Oct 13 20:43:08 2008 (r183844) @@ -85,28 +85,8 @@ e-Tek Labs Kwik232 .It GoHubs GoCOM232 .It -Huawei Technologies Mobile card (3G) -.It -Novatel Wireless Merlin U740 (only basic modem port supported) -.It -Option Globetrotter 3G (aka Vodafone Mobile Connect Card 3G) -.It -Option Globetrotter 3G Quad -.It -Option Globetrotter 3G Fusion (no WLAN support, only basic 3G modem port) -.It -Option Globetrotter 3G Fusion Quad (no WLAN support) -.It -Option Globetrotter Max 3.6 -.It Peracom single port serial adapter -.It -Qualcomm, Inc. ZTE CDMA Technologies MSM .El -.Pp -The supported 3G cards provide the necessary modem port for ppp, -pppd, or mpd connections; other functions of these cards (diagnostic port, -SIM toolkit port, WLAN) are not supported. .Sh SEE ALSO .Xr tty 4 , .Xr ucom 4 , Modified: head/share/man/man4/umass.4 ============================================================================== --- head/share/man/man4/umass.4 Mon Oct 13 20:41:11 2008 (r183843) +++ head/share/man/man4/umass.4 Mon Oct 13 20:43:08 2008 (r183844) @@ -85,6 +85,8 @@ FujiFilm Zip USB Drive ZDR100 USB A .It GREEN HOUSE USB Flash Memory "PicoDrive" GH-UFD32M, 64M, 128M .It +Huawei Mobile (SD slot) +.It IBM 32MB USB Memory Key (P/N 22P5296) .It IBM 256MB USB Drive (MSYSTEM DiskOnKey2) From brueffer at FreeBSD.org Mon Oct 13 21:02:19 2008 From: brueffer at FreeBSD.org (Christian Brueffer) Date: Mon Oct 13 21:02:31 2008 Subject: svn commit: r183845 - head/release/doc/en_US.ISO8859-1/hardware Message-ID: <200810132102.m9DL2JlL086307@svn.freebsd.org> Author: brueffer Date: Mon Oct 13 21:02:19 2008 New Revision: 183845 URL: http://svn.freebsd.org/changeset/base/183845 Log: Mention iwn(4) and malo(4). Note that the malo entry doesn't suck in the hardware adapter list from the manpage yet, as man2hwnotes.pl doesn't grok the table format. Modified: head/release/doc/en_US.ISO8859-1/hardware/article.sgml Modified: head/release/doc/en_US.ISO8859-1/hardware/article.sgml ============================================================================== --- head/release/doc/en_US.ISO8859-1/hardware/article.sgml Mon Oct 13 20:43:08 2008 (r183844) +++ head/release/doc/en_US.ISO8859-1/hardware/article.sgml Mon Oct 13 21:02:19 2008 (r183845) @@ -822,6 +822,13 @@ 2200BG/2915ABG MiniPCI and 2225BG PCI network adapters (&man.iwi.4; driver) + [&arch.i386;, &arch.amd64;] Intel Wireless WiFi Link + 4965AGN IEEE 802.11n PCI network adapters + (&man.iwn.4; driver) + + [&arch.i386;, &arch.amd64;] Marvell Libertas IEEE 802.11b/g + PCI network adapters (&man.malo.4; driver) + &hwlist.ral; [&arch.i386;, &arch.pc98;] Raytheon Raylink 2.4GHz From rdivacky at FreeBSD.org Mon Oct 13 21:04:52 2008 From: rdivacky at FreeBSD.org (Roman Divacky) Date: Mon Oct 13 21:05:03 2008 Subject: svn commit: r183846 - head/sys/kern Message-ID: <200810132104.m9DL4qxE086381@svn.freebsd.org> Author: rdivacky Date: Mon Oct 13 21:04:52 2008 New Revision: 183846 URL: http://svn.freebsd.org/changeset/base/183846 Log: Check the result of copyin and in a case of error return one. This prevents setting wrong priority or (more likely) returning EINVAL. Approved by: kib (mentor) Modified: head/sys/kern/kern_thr.c Modified: head/sys/kern/kern_thr.c ============================================================================== --- head/sys/kern/kern_thr.c Mon Oct 13 21:02:19 2008 (r183845) +++ head/sys/kern/kern_thr.c Mon Oct 13 21:04:52 2008 (r183846) @@ -126,6 +126,8 @@ kern_thr_new(struct thread *td, struct t rtpp = NULL; if (param->rtp != 0) { error = copyin(param->rtp, &rtp, sizeof(struct rtprio)); + if (error) + return (error); rtpp = &rtp; } error = create_thread(td, NULL, param->start_func, param->arg, From delphij at FreeBSD.org Mon Oct 13 22:50:38 2008 From: delphij at FreeBSD.org (Xin LI) Date: Mon Oct 13 22:50:44 2008 Subject: svn commit: r183857 - head/usr.bin/tftp Message-ID: <200810132250.m9DMocb1088816@svn.freebsd.org> Author: delphij Date: Mon Oct 13 22:50:38 2008 New Revision: 183857 URL: http://svn.freebsd.org/changeset/base/183857 Log: Use strlcpy() instead of strncpy() when we want the string to be NUL-terminated. Modified: head/usr.bin/tftp/main.c Modified: head/usr.bin/tftp/main.c ============================================================================== --- head/usr.bin/tftp/main.c Mon Oct 13 22:04:41 2008 (r183856) +++ head/usr.bin/tftp/main.c Mon Oct 13 22:50:38 2008 (r183857) @@ -233,11 +233,10 @@ setpeer0(host, port) /* res->ai_addr <= sizeof(peeraddr) is guaranteed */ memcpy(&peeraddr, res->ai_addr, res->ai_addrlen); if (res->ai_canonname) { - (void) strncpy(hostname, res->ai_canonname, + (void) strlcpy(hostname, res->ai_canonname, sizeof(hostname)); } else - (void) strncpy(hostname, host, sizeof(hostname)); - hostname[sizeof(hostname)-1] = 0; + (void) strlcpy(hostname, host, sizeof(hostname)); connected = 1; } From delphij at FreeBSD.org Mon Oct 13 23:10:19 2008 From: delphij at FreeBSD.org (Xin LI) Date: Mon Oct 13 23:10:25 2008 Subject: svn commit: r183858 - head/usr.bin/tftp Message-ID: <200810132310.m9DNAJeD089204@svn.freebsd.org> Author: delphij Date: Mon Oct 13 23:10:19 2008 New Revision: 183858 URL: http://svn.freebsd.org/changeset/base/183858 Log: ANSIfy, plus constify interfaces where possible. Modified: head/usr.bin/tftp/extern.h head/usr.bin/tftp/main.c head/usr.bin/tftp/tftp.c head/usr.bin/tftp/tftpsubs.c Modified: head/usr.bin/tftp/extern.h ============================================================================== --- head/usr.bin/tftp/extern.h Mon Oct 13 22:50:38 2008 (r183857) +++ head/usr.bin/tftp/extern.h Mon Oct 13 23:10:19 2008 (r183858) @@ -34,5 +34,5 @@ * $FreeBSD$ */ -void recvfile(int, char *, char *); -void xmitfile(int, char *, char *); +void recvfile(int, const char *, const char *); +void xmitfile(int, const char *, const char *); Modified: head/usr.bin/tftp/main.c ============================================================================== --- head/usr.bin/tftp/main.c Mon Oct 13 22:50:38 2008 (r183857) +++ head/usr.bin/tftp/main.c Mon Oct 13 23:10:19 2008 (r183858) @@ -109,9 +109,9 @@ void status(int, char **); static void command(void) __dead2; static const char *command_prompt(void); -static void getusage(char *); +static void getusage(const char *); static void makeargv(void); -static void putusage(char *); +static void putusage(const char *); static void settftpmode(const char *); char *tail(char *); @@ -157,9 +157,7 @@ struct cmd cmdtab[] = { }; int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { f = -1; strcpy(mode, "netascii"); @@ -177,9 +175,7 @@ main(argc, argv) char hostname[MAXHOSTNAMELEN]; void -setpeer0(host, port) - char *host; - const char *port; +setpeer0(char *host, const char *port) { struct addrinfo hints, *res0, *res; int error; @@ -244,9 +240,7 @@ setpeer0(host, port) } void -setpeer(argc, argv) - int argc; - char *argv[]; +setpeer(int argc, char *argv[]) { if (argc < 2) { @@ -281,9 +275,7 @@ struct modes { }; void -modecmd(argc, argv) - int argc; - char *argv[]; +modecmd(int argc, char *argv[]) { struct modes *p; const char *sep; @@ -316,26 +308,21 @@ modecmd(argc, argv) } void -setbinary(argc, argv) - int argc __unused; - char *argv[] __unused; +setbinary(int argc __unused, char *argv[] __unused) { settftpmode("octet"); } void -setascii(argc, argv) - int argc __unused; - char *argv[] __unused; +setascii(int argc __unused, char *argv[] __unused) { settftpmode("netascii"); } static void -settftpmode(newmode) - const char *newmode; +settftpmode(const char *newmode) { strcpy(mode, newmode); if (verbose) @@ -347,9 +334,7 @@ settftpmode(newmode) * Send file(s). */ void -put(argc, argv) - int argc; - char *argv[]; +put(int argc, char *argv[]) { int fd; int n; @@ -421,8 +406,7 @@ put(argc, argv) } static void -putusage(s) - char *s; +putusage(const char *s) { printf("usage: %s file [[host:]remotename]\n", s); printf(" %s file1 file2 ... fileN [[host:]remote-directory]\n", s); @@ -432,9 +416,7 @@ putusage(s) * Receive file(s). */ void -get(argc, argv) - int argc; - char *argv[]; +get(int argc, char *argv[]) { int fd; int n; @@ -504,8 +486,7 @@ get(argc, argv) } static void -getusage(s) - char *s; +getusage(const char *s) { printf("usage: %s [host:]file [localname]\n", s); printf(" %s [host1:]file1 [host2:]file2 ... [hostN:]fileN\n", s); @@ -514,9 +495,7 @@ getusage(s) int rexmtval = TIMEOUT; void -setrexmt(argc, argv) - int argc; - char *argv[]; +setrexmt(int argc, char *argv[]) { int t; @@ -542,9 +521,7 @@ setrexmt(argc, argv) int maxtimeout = 5 * TIMEOUT; void -settimeout(argc, argv) - int argc; - char *argv[]; +settimeout(int argc, char *argv[]) { int t; @@ -568,9 +545,7 @@ settimeout(argc, argv) } void -status(argc, argv) - int argc __unused; - char *argv[] __unused; +status(int argc __unused, char *argv[] __unused) { if (connected) printf("Connected to %s.\n", hostname); @@ -583,8 +558,7 @@ status(argc, argv) } void -intr(dummy) - int dummy __unused; +intr(int dummy __unused) { signal(SIGALRM, SIG_IGN); @@ -593,8 +567,7 @@ intr(dummy) } char * -tail(filename) - char *filename; +tail(char *filename) { char *s; @@ -610,7 +583,7 @@ tail(filename) } static const char * -command_prompt() +command_prompt(void) { return ("tftp> "); @@ -620,7 +593,7 @@ command_prompt() * Command parser. */ static void -command() +command(void) { HistEvent he; struct cmd *c; @@ -679,8 +652,7 @@ command() } struct cmd * -getcmd(name) - char *name; +getcmd(char *name) { const char *p, *q; struct cmd *c, *found; @@ -711,7 +683,7 @@ getcmd(name) * Slice a string up into argc/argv. */ static void -makeargv() +makeargv(void) { char *cp; char **argp = margv; @@ -736,9 +708,7 @@ makeargv() } void -quit(argc, argv) - int argc __unused; - char *argv[] __unused; +quit(int argc __unused, char *argv[] __unused) { exit(txrx_error); } @@ -747,9 +717,7 @@ quit(argc, argv) * Help command. */ void -help(argc, argv) - int argc; - char *argv[]; +help(int argc, char *argv[]) { struct cmd *c; @@ -773,18 +741,14 @@ help(argc, argv) } void -settrace(argc, argv) - int argc __unused; - char **argv __unused; +settrace(int argc __unused, char **argv __unused) { trace = !trace; printf("Packet tracing %s.\n", trace ? "on" : "off"); } void -setverbose(argc, argv) - int argc __unused; - char **argv __unused; +setverbose(int argc __unused, char **argv __unused) { verbose = !verbose; printf("Verbose mode %s.\n", verbose ? "on" : "off"); Modified: head/usr.bin/tftp/tftp.c ============================================================================== --- head/usr.bin/tftp/tftp.c Mon Oct 13 22:50:38 2008 (r183857) +++ head/usr.bin/tftp/tftp.c Mon Oct 13 23:10:19 2008 (r183858) @@ -80,23 +80,20 @@ int timeout; jmp_buf toplevel; jmp_buf timeoutbuf; -static void nak(int, struct sockaddr *); +static void nak(int, const struct sockaddr *); static int makerequest(int, const char *, struct tftphdr *, const char *); static void printstats(const char *, unsigned long); static void startclock(void); static void stopclock(void); static void timer(int); static void tpacket(const char *, struct tftphdr *, int); -static int cmpport(struct sockaddr *, struct sockaddr *); +static int cmpport(const struct sockaddr *, const struct sockaddr *); /* * Send the requested file. */ void -xmitfile(fd, name, mode) - int fd; - char *name; - char *mode; +xmitfile(int fd, const char *name, const char *mode) { struct tftphdr *ap; /* data and ack packets */ struct tftphdr *dp; @@ -212,10 +209,7 @@ abort: * Receive a file. */ void -recvfile(fd, name, mode) - int fd; - char *name; - char *mode; +recvfile(int fd, const char *name, const char *mode) { struct tftphdr *ap; struct tftphdr *dp; @@ -335,11 +329,7 @@ abort: /* ok to ack, since user */ } static int -makerequest(request, name, tp, mode) - int request; - const char *name; - struct tftphdr *tp; - const char *mode; +makerequest(int request, const char *name, struct tftphdr *tp, const char *mode) { char *cp; @@ -376,9 +366,7 @@ struct errmsg { * offset by 100. */ static void -nak(error, peer) - int error; - struct sockaddr *peer; +nak(int error, const struct sockaddr *peer) { struct errmsg *pe; struct tftphdr *tp; @@ -403,10 +391,7 @@ nak(error, peer) } static void -tpacket(s, tp, n) - const char *s; - struct tftphdr *tp; - int n; +tpacket(const char *s, struct tftphdr *tp, int n) { static const char *opcodes[] = { "#0", "RRQ", "WRQ", "DATA", "ACK", "ERROR" }; @@ -445,23 +430,21 @@ struct timeval tstart; struct timeval tstop; static void -startclock() +startclock(void) { (void)gettimeofday(&tstart, NULL); } static void -stopclock() +stopclock(void) { (void)gettimeofday(&tstop, NULL); } static void -printstats(direction, amount) - const char *direction; - unsigned long amount; +printstats(const char *direction, unsigned long amount) { double delta; /* compute delta in 1/10's second units */ @@ -475,8 +458,7 @@ printstats(direction, amount) } static void -timer(sig) - int sig __unused; +timer(int sig __unused) { timeout += rexmtval; @@ -489,9 +471,7 @@ timer(sig) } static int -cmpport(sa, sb) - struct sockaddr *sa; - struct sockaddr *sb; +cmpport(const struct sockaddr *sa, const struct sockaddr *sb) { char a[NI_MAXSERV], b[NI_MAXSERV]; Modified: head/usr.bin/tftp/tftpsubs.c ============================================================================== --- head/usr.bin/tftp/tftpsubs.c Mon Oct 13 22:50:38 2008 (r183857) +++ head/usr.bin/tftp/tftpsubs.c Mon Oct 13 23:10:19 2008 (r183858) @@ -85,9 +85,8 @@ static struct tftphdr *rw_init(int); struct tftphdr *w_init(void) { return rw_init(0); } /* write-behind */ struct tftphdr *r_init(void) { return rw_init(1); } /* read-ahead */ -static struct tftphdr * -rw_init(x) /* init for either read-ahead or write-behind */ - int x; /* zero for write-behind, one for read-head */ +static struct tftphdr * /* init for either read-ahead or write-behind */ +rw_init(int x) /* zero for write-behind, one for read-head */ { newline = 0; /* init crlf flag */ prevchar = -1; @@ -103,10 +102,9 @@ rw_init(x) /* init for either read-ahe Free it and return next buffer filled with data. */ int -readit(file, dpp, convert) - FILE *file; /* file opened for read */ - struct tftphdr **dpp; - int convert; /* if true, convert to ascii */ +readit(FILE *file, /* file opened for read */ + struct tftphdr **dpp, + int convert) /* if true, convert to ascii */ { struct bf *b; @@ -126,9 +124,8 @@ readit(file, dpp, convert) * conversions are lf -> cr,lf and cr -> cr, nul */ void -read_ahead(file, convert) - FILE *file; /* file opened for read */ - int convert; /* if true, convert to ascii */ +read_ahead(FILE *file, /* file opened for read */ + int convert) /* if true, convert to ascii */ { register int i; register char *p; @@ -175,10 +172,7 @@ read_ahead(file, convert) available. */ int -writeit(file, dpp, ct, convert) - FILE *file; - struct tftphdr **dpp; - int ct, convert; +writeit(FILE *file, struct tftphdr **dpp, int ct, int convert) { bfs[current].counter = ct; /* set size of data to write */ current = !current; /* switch to other buffer */ @@ -196,9 +190,7 @@ writeit(file, dpp, ct, convert) * CR followed by anything else. In this case we leave it alone. */ int -write_behind(file, convert) - FILE *file; - int convert; +write_behind(FILE *file, int convert) { char *buf; int count; @@ -255,8 +247,7 @@ skipit: */ int -synchnet(f) - int f; /* socket to flush */ +synchnet(int f) /* socket to flush */ { int i, j = 0; char rbuf[PKTSIZE]; From yongari at FreeBSD.org Tue Oct 14 00:54:15 2008 From: yongari at FreeBSD.org (Pyun YongHyeon) Date: Tue Oct 14 00:54:27 2008 Subject: svn commit: r183859 - head/sys/dev/jme Message-ID: <200810140054.m9E0sFKY091002@svn.freebsd.org> Author: yongari Date: Tue Oct 14 00:54:15 2008 New Revision: 183859 URL: http://svn.freebsd.org/changeset/base/183859 Log: Make sure to read the last byte of EEPROM descriptor. Previously the last byte of the ethernet address was not read which in turn resulted in getting 5 out of the 6 bytes of ethernet address and always returned ENOENT. I did not notice the bug on FPGA version because of additional configuration data in EEPROM. Pointed out by: bouyer at NetBSD Modified: head/sys/dev/jme/if_jme.c Modified: head/sys/dev/jme/if_jme.c ============================================================================== --- head/sys/dev/jme/if_jme.c Mon Oct 13 23:10:19 2008 (r183858) +++ head/sys/dev/jme/if_jme.c Tue Oct 14 00:54:15 2008 (r183859) @@ -415,11 +415,8 @@ jme_eeprom_macaddr(struct jme_softc *sc) do { if (jme_eeprom_read_byte(sc, offset, &fup) != 0) break; - /* Check for the end of EEPROM descriptor. */ - if ((fup & JME_EEPROM_DESC_END) == JME_EEPROM_DESC_END) - break; - if ((uint8_t)JME_EEPROM_MKDESC(JME_EEPROM_FUNC0, - JME_EEPROM_PAGE_BAR1) == fup) { + if (JME_EEPROM_MKDESC(JME_EEPROM_FUNC0, JME_EEPROM_PAGE_BAR1) == + (fup & (JME_EEPROM_FUNC_MASK | JME_EEPROM_PAGE_MASK))) { if (jme_eeprom_read_byte(sc, offset + 1, ®) != 0) break; if (reg >= JME_PAR0 && @@ -431,6 +428,9 @@ jme_eeprom_macaddr(struct jme_softc *sc) match++; } } + /* Check for the end of EEPROM descriptor. */ + if ((fup & JME_EEPROM_DESC_END) == JME_EEPROM_DESC_END) + break; /* Try next eeprom descriptor. */ offset += JME_EEPROM_DESC_BYTES; } while (match != ETHER_ADDR_LEN && offset < JME_EEPROM_END); From kensmith at FreeBSD.org Tue Oct 14 02:13:13 2008 From: kensmith at FreeBSD.org (Ken Smith) Date: Tue Oct 14 02:13:19 2008 Subject: svn commit: r183860 - head/release Message-ID: <200810140213.m9E2DDl7092616@svn.freebsd.org> Author: kensmith Date: Tue Oct 14 02:13:12 2008 New Revision: 183860 URL: http://svn.freebsd.org/changeset/base/183860 Log: The thought of making more than one DVD image for a release really freaks me out. But it turns out we might be able to generalize a few of the other things RE uses to assemble the package trees for releases if the DVDs use a naming theme close to what is used for the CDROMS (disc1, disc2, etc). So change the name to dvd1. Hopefully this way src/release/scripts/{package-split.py,package-trees.sh} can be generalized instead of copied-and-hacked. MFC after: 5 days Modified: head/release/Makefile Modified: head/release/Makefile ============================================================================== --- head/release/Makefile Tue Oct 14 00:54:15 2008 (r183859) +++ head/release/Makefile Tue Oct 14 02:13:12 2008 (r183860) @@ -265,7 +265,7 @@ CD_BOOT= ${CD}/bootonly CD_DISC1= ${CD}/disc1 CD_DISC2= ${CD}/disc2 .if defined(MAKE_DVD) -CD_DVD= ${CD}/dvd +CD_DVD1= ${CD}/dvd1 .endif .if !defined(NODOC) CD_DOCS= ${CD}/docs @@ -930,13 +930,13 @@ cdrom.1: done .if defined(MAKE_DVD) @echo "Building DVD filesystem image as well as CDROM" - @mkdir -p ${CD_DVD}/${BUILDNAME} + @mkdir -p ${CD_DVD1}/${BUILDNAME} @for i in ${DISTRIBUTIONS} ; \ do \ if [ -d ${RD}/trees/$${i} ] ; then \ chflags -R noschg ${RD}/trees/$${i} || true ; \ ( cd ${RD}/trees/$${i} && \ - find . -depth -print | cpio -dumpl ${CD_DVD} ) ; \ + find . -depth -print | cpio -dumpl ${CD_DVD1} ) ; \ fi \ done .endif @@ -958,21 +958,21 @@ cdrom.1: @cp ${RD}/trees/base/boot/device.hints ${CD_LIVEFS}/boot/device.hints .endif .if defined(MAKE_DVD) - @cp -Rp ${RD}/kernels/GENERIC/ ${CD_DVD}/boot/kernel - @rm -f ${CD_DVD}/boot/kernel/*.symbols - @rm -f ${CD_DVD}/.profile - @cp ${.CURDIR}/fixit.profile ${CD_DVD}/.profile - @ln -sf /rescue ${CD_DVD}/stand + @cp -Rp ${RD}/kernels/GENERIC/ ${CD_DVD1}/boot/kernel + @rm -f ${CD_DVD1}/boot/kernel/*.symbols + @rm -f ${CD_DVD1}/.profile + @cp ${.CURDIR}/fixit.profile ${CD_DVD1}/.profile + @ln -sf /rescue ${CD_DVD1}/stand @echo "CD_VERSION = ${BUILDNAME}" > ${CD_LIVEFS}/cdrom.inf - @echo "CD_VERSION = ${BUILDNAME}" > ${CD_DVD}/cdrom.inf - @rm -f ${CD_DVD}/boot/loader.conf - @cp ${RD}/mfsroot/mfsroot.gz ${CD_DVD}/boot/mfsroot.gz - @echo 'mfsroot_load="YES"' > ${CD_DVD}/boot/loader.conf - @echo 'mfsroot_type="mfs_root"' >> ${CD_DVD}/boot/loader.conf - @echo 'mfsroot_name="/boot/mfsroot"' >> ${CD_DVD}/boot/loader.conf + @echo "CD_VERSION = ${BUILDNAME}" > ${CD_DVD1}/cdrom.inf + @rm -f ${CD_DVD1}/boot/loader.conf + @cp ${RD}/mfsroot/mfsroot.gz ${CD_DVD1}/boot/mfsroot.gz + @echo 'mfsroot_load="YES"' > ${CD_DVD1}/boot/loader.conf + @echo 'mfsroot_type="mfs_root"' >> ${CD_DVD1}/boot/loader.conf + @echo 'mfsroot_name="/boot/mfsroot"' >> ${CD_DVD1}/boot/loader.conf .if exists(${RD}/trees/base/boot/device.hints) - @rm -f ${CD_DVD}/boot/device.hints - @cp ${RD}/trees/base/boot/device.hints ${CD_DVD}/boot/device.hints + @rm -f ${CD_DVD1}/boot/device.hints + @cp ${RD}/trees/base/boot/device.hints ${CD_DVD1}/boot/device.hints .endif .endif touch ${.TARGET} @@ -1011,26 +1011,26 @@ cdrom.2: @echo "CD_VOLUME = 2" >> ${CD_DISC2}/cdrom.inf .if defined(MAKE_DVD) .if defined(MAKE_FLOPPIES) - @cd ${RD} && find floppies -print | cpio -dumpl ${CD_DVD} + @cd ${RD} && find floppies -print | cpio -dumpl ${CD_DVD1} .endif - @cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DVD}/${BUILDNAME} + @cd ${RD}/dists && find . -print | cpio -dumpl ${CD_DVD1}/${BUILDNAME} .if !defined(NODOC) @for i in ${DIST_DOCS_ARCH_INDEP}; do \ cp ${RND}/${RELNOTES_LANG}/$$i/article.txt \ - ${CD_DVD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \ + ${CD_DVD1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \ cp ${RND}/${RELNOTES_LANG}/$$i/article.html \ - ${CD_DVD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \ + ${CD_DVD1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \ done @for i in ${DIST_DOCS_ARCH_DEP}; do \ cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.txt \ - ${CD_DVD}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \ + ${CD_DVD1}/`echo $${i} | tr 'a-z' 'A-Z'`.TXT; \ cp ${RND}/${RELNOTES_LANG}/$$i/${TARGET}/article.html \ - ${CD_DVD}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \ + ${CD_DVD1}/`echo $${i} | tr 'a-z' 'A-Z'`.HTM; \ done - @cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${CD_DVD} + @cp ${RND}/${RELNOTES_LANG}/readme/docbook.css ${CD_DVD1} .endif - @echo "CD_VERSION = ${BUILDNAME}" > ${CD_DVD}/cdrom.inf - @echo "CD_VOLUME = 1" >> ${CD_DVD}/cdrom.inf + @echo "CD_VERSION = ${BUILDNAME}" > ${CD_DVD1}/cdrom.inf + @echo "CD_VOLUME = 1" >> ${CD_DVD1}/cdrom.inf .endif .if !defined(NODOC) echo "Building CDROM docs filesystem image" @@ -1038,7 +1038,7 @@ cdrom.2: @echo "CD_VERSION = ${BUILDNAME}" > ${CD_DOCS}/cdrom.inf @mkdir -p ${CD_DOCS}/usr/share/doc .if defined(MAKE_DVD) - @mkdir -p ${CD_DVD}/usr/share/doc + @mkdir -p ${CD_DVD1}/usr/share/doc .endif @for i in `ls ${CD_LIVEFS}/usr/share/doc`; do \ if [ -L ${CD_LIVEFS}/usr/share/doc/$$i -o \ @@ -1049,7 +1049,7 @@ cdrom.2: done .if defined(MAKE_DVD) @cd ${CD_DOCS}/usr/share/doc && find . -print | \ - cpio -dumpl ${CD_DVD}/usr/share/doc + cpio -dumpl ${CD_DVD1}/usr/share/doc .endif .endif touch ${.TARGET} @@ -1081,8 +1081,8 @@ CD_DISC1_PKGS= ${CD_PACKAGE_TREE}/disc1 .if exists(${CD_PACKAGE_TREE}/disc2) CD_DISC2_PKGS= ${CD_PACKAGE_TREE}/disc2 .endif -.if exists(${CD_PACKAGE_TREE}/dvd) -CD_DVD_PKGS= ${CD_PACKAGE_TREE}/dvd +.if exists(${CD_PACKAGE_TREE}/dvd1) +CD_DVD1_PKGS= ${CD_PACKAGE_TREE}/dvd1 .endif .endif .endif @@ -1106,8 +1106,8 @@ iso.1: .if defined(MAKE_DVD) @sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh ${BOOTABLE} \ FreeBSD_Install \ - ${CD}/${BUILDNAME}-${TARGET}-dvd.iso ${CD_DVD} \ - ${CD_DVD_PKGS} + ${CD}/${BUILDNAME}-${TARGET}-dvd1.iso ${CD_DVD1} \ + ${CD_DVD1_PKGS} .endif .if !defined(NODOC) @sh ${.CURDIR}/${TARGET_ARCH}/mkisoimages.sh \ From rodrigc at crodrigues.org Tue Oct 14 02:22:42 2008 From: rodrigc at crodrigues.org (Craig Rodrigues) Date: Tue Oct 14 02:22:48 2008 Subject: svn commit: r183754 - in head/sys: cddl/contrib/opensolaris/uts/common/fs/zfs fs/cd9660 fs/hpfs fs/msdosfs fs/ntfs fs/nwfs fs/smbfs fs/udf geom gnu/fs/ext2fs gnu/fs/xfs/FreeBSD kern nfsclient sys u... In-Reply-To: <200810102123.m9ALNpou001340@svn.freebsd.org> References: <200810102123.m9ALNpou001340@svn.freebsd.org> Message-ID: <20081014022242.GA80660@crodrigues.org> On Fri, Oct 10, 2008 at 09:23:51PM +0000, Attilio Rao wrote: > - error = vinvalbuf(vp, V_SAVE, curthread, 0, 0); > + error = vinvalbuf(vp, V_SAVE, 0, 0); > vnode_pager_setsize(vp, end); > #endif > } Hi, Can you update the vinvalbuf.9 man page (and any other man pages for functions which you changed with your commit)? Thanks. -- Craig Rodrigues rodrigc@crodrigues.org From nwhitehorn at FreeBSD.org Tue Oct 14 03:32:42 2008 From: nwhitehorn at FreeBSD.org (Nathan Whitehorn) Date: Tue Oct 14 03:32:49 2008 Subject: svn commit: r183863 - in head/sys/boot/powerpc: . boot1.chrp Message-ID: <200810140332.m9E3WfEK094381@svn.freebsd.org> Author: nwhitehorn Date: Tue Oct 14 03:32:41 2008 New Revision: 183863 URL: http://svn.freebsd.org/changeset/base/183863 Log: Add a simple HFS boot block implementation for booting PowerPC macs. It creates a small HFS filesystem with a CHRP boot script and an early-stage bootloader derived from the sparc64 boot block. Obtained from: sparc64 Added: head/sys/boot/powerpc/boot1.chrp/ head/sys/boot/powerpc/boot1.chrp/Makefile (contents, props changed) head/sys/boot/powerpc/boot1.chrp/Makefile.hfs (contents, props changed) head/sys/boot/powerpc/boot1.chrp/boot1.c (contents, props changed) head/sys/boot/powerpc/boot1.chrp/bootinfo.txt (contents, props changed) head/sys/boot/powerpc/boot1.chrp/generate-hfs.sh (contents, props changed) head/sys/boot/powerpc/boot1.chrp/hfs.tmpl.bz2.uu (contents, props changed) Modified: head/sys/boot/powerpc/Makefile Modified: head/sys/boot/powerpc/Makefile ============================================================================== --- head/sys/boot/powerpc/Makefile Tue Oct 14 03:22:38 2008 (r183862) +++ head/sys/boot/powerpc/Makefile Tue Oct 14 03:32:41 2008 (r183863) @@ -1,5 +1,5 @@ # $FreeBSD$ -SUBDIR= ofw uboot +SUBDIR= boot1.chrp ofw uboot .include Added: head/sys/boot/powerpc/boot1.chrp/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/powerpc/boot1.chrp/Makefile Tue Oct 14 03:32:41 2008 (r183863) @@ -0,0 +1,42 @@ +# $FreeBSD$ + +WITHOUT_SSP= + +PROG= boot1.elf +NEWVERSWHAT= "Open Firmware boot block" ${MACHINE_ARCH} +BINDIR?= /boot +INSTALLFLAGS= -b + +FILES= boot1.hfs +SRCS= boot1.c ashldi3.c + +INTERNALPROG= +NO_MAN= + +CFLAGS= -ffreestanding -msoft-float -Os -D_KERNEL \ + -I${.CURDIR}/../../common -I${.CURDIR}/../../../ +LDFLAGS=-nostdlib -static -N + +.include "${.CURDIR}/../Makefile.inc" +.PATH: ${.CURDIR}/../../../libkern ${.CURDIR} + +# The following inserts out objects into a template HFS +# created by generate-hfs.sh + +.include "${.CURDIR}/Makefile.hfs" + +boot1.hfs: boot1.elf bootinfo.txt + echo ${.OBJDIR} + uudecode ${.CURDIR}/hfs.tmpl.bz2.uu + mv hfs.tmpl.bz2 ${.TARGET}.bz2 + bzip2 -f -d ${.TARGET}.bz2 + dd if=boot1.elf of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc + dd if=${.CURDIR}/bootinfo.txt of=${.TARGET} seek=${BOOTINFO_OFFSET} \ + conv=notrunc + +CLEANFILES= boot1.hfs + +boot1.o: ${.CURDIR}/../../common/ufsread.c + +.include + Added: head/sys/boot/powerpc/boot1.chrp/Makefile.hfs ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/powerpc/boot1.chrp/Makefile.hfs Tue Oct 14 03:32:41 2008 (r183863) @@ -0,0 +1,4 @@ +# This file autogenerated by generate-hfs.sh - DO NOT EDIT +# $FreeBSD$ +BOOTINFO_OFFSET=0x58 +BOOT1_OFFSET=0x1c Added: head/sys/boot/powerpc/boot1.chrp/boot1.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/powerpc/boot1.chrp/boot1.c Tue Oct 14 03:32:41 2008 (r183863) @@ -0,0 +1,764 @@ +/*- + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * Copyright (c) 2001 Robert Drehmel + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#define _PATH_LOADER "/boot/loader" +#define _PATH_KERNEL "/boot/kernel/kernel" + +#define BSIZEMAX 16384 + +typedef int putc_func_t(char c, void *arg); +typedef int32_t ofwh_t; + +struct sp_data { + char *sp_buf; + u_int sp_len; + u_int sp_size; +}; + +static const char digits[] = "0123456789abcdef"; + +static char bootpath[128]; +static char bootargs[128]; + +static ofwh_t bootdev; + +static struct fs fs; +static ino_t inomap; +static char blkbuf[BSIZEMAX]; +static unsigned int fsblks; + +static uint32_t fs_off; + +int main(int ac, char **av); + +static void exit(int) __dead2; +static void load(const char *); +static int dskread(void *, u_int64_t, int); + +static void usage(void); + +static void bcopy(const void *src, void *dst, size_t len); +static void bzero(void *b, size_t len); + +static int mount(const char *device, int quiet); + +static void panic(const char *fmt, ...) __dead2; +static int printf(const char *fmt, ...); +static int putchar(char c, void *arg); +static int vprintf(const char *fmt, va_list ap); +static int vsnprintf(char *str, size_t sz, const char *fmt, va_list ap); + +static int __printf(const char *fmt, putc_func_t *putc, void *arg, va_list ap); +static int __putc(char c, void *arg); +static int __puts(const char *s, putc_func_t *putc, void *arg); +static int __sputc(char c, void *arg); +static char *__uitoa(char *buf, u_int val, int base); +static char *__ultoa(char *buf, u_long val, int base); + +/* + * Open Firmware interface functions + */ +typedef u_int32_t ofwcell_t; +typedef u_int32_t u_ofwh_t; +typedef int (*ofwfp_t)(void *); +ofwfp_t ofw; /* the prom Open Firmware entry */ +ofwh_t chosenh; + +void ofw_init(void *, int, int (*)(void *), char *, int); +static ofwh_t ofw_finddevice(const char *); +static ofwh_t ofw_open(const char *); +static int ofw_close(ofwh_t); +static int ofw_getprop(ofwh_t, const char *, void *, size_t); +static int ofw_setprop(ofwh_t, const char *, void *, size_t); +static int ofw_read(ofwh_t, void *, size_t); +static int ofw_write(ofwh_t, const void *, size_t); +static int ofw_claim(void *virt, size_t len, u_int align); +static int ofw_seek(ofwh_t, u_int64_t); +static void ofw_exit(void) __dead2; + +ofwh_t bootdevh; +ofwh_t stdinh, stdouth; + +__asm(" \n\ + .data \n\ +stack: \n\ + .space 16384 \n\ + \n\ + .text \n\ + .globl _start \n\ +_start: \n\ + lis %r1,stack@ha \n\ + addi %r1,%r1,stack@l \n\ + addi %r1,%r1,8192 \n\ + \n\ + b ofw_init \n\ +"); + +void +ofw_init(void *vpd, int res, int (*openfirm)(void *), char *arg, int argl) +{ + char *av[16]; + char *p; + int ac; + + ofw = openfirm; + + chosenh = ofw_finddevice("/chosen"); + ofw_getprop(chosenh, "stdin", &stdinh, sizeof(stdinh)); + ofw_getprop(chosenh, "stdout", &stdouth, sizeof(stdouth)); + ofw_getprop(chosenh, "bootargs", bootargs, sizeof(bootargs)); + ofw_getprop(chosenh, "bootpath", bootpath, sizeof(bootpath)); + + bootargs[sizeof(bootargs) - 1] = '\0'; + bootpath[sizeof(bootpath) - 1] = '\0'; + + p = bootpath; + while (*p != '\0') { + if (*p == ':') { + *(++p) = '\0'; + break; + } + p++; + } + + ac = 0; + p = bootargs; + for (;;) { + while (*p == ' ' && *p != '\0') + p++; + if (*p == '\0' || ac >= 16) + break; + av[ac++] = p; + while (*p != ' ' && *p != '\0') + p++; + if (*p != '\0') + *p++ = '\0'; + } + + exit(main(ac, av)); +} + +static ofwh_t +ofw_finddevice(const char *name) +{ + ofwcell_t args[] = { + (ofwcell_t)"finddevice", + 1, + 1, + (ofwcell_t)name, + 0 + }; + + if ((*ofw)(args)) { + printf("ofw_finddevice: name=\"%s\"\n", name); + return (1); + } + return (args[4]); +} + +static int +ofw_getprop(ofwh_t ofwh, const char *name, void *buf, size_t len) +{ + ofwcell_t args[] = { + (ofwcell_t)"getprop", + 4, + 1, + (u_ofwh_t)ofwh, + (ofwcell_t)name, + (ofwcell_t)buf, + len, + 0 + }; + + if ((*ofw)(args)) { + printf("ofw_getprop: ofwh=0x%x buf=%p len=%u\n", + ofwh, buf, len); + return (1); + } + return (0); +} + +static int +ofw_setprop(ofwh_t ofwh, const char *name, void *buf, size_t len) +{ + ofwcell_t args[] = { + (ofwcell_t)"setprop", + 4, + 1, + (u_ofwh_t)ofwh, + (ofwcell_t)name, + (ofwcell_t)buf, + len, + 0 + }; + + if ((*ofw)(args)) { + printf("ofw_setprop: ofwh=0x%x buf=%p len=%u\n", + ofwh, buf, len); + return (1); + } + return (0); +} + +static ofwh_t +ofw_open(const char *path) +{ + ofwcell_t args[] = { + (ofwcell_t)"open", + 1, + 1, + (ofwcell_t)path, + 0 + }; + + if ((*ofw)(args)) { + printf("ofw_open: path=\"%s\"\n", path); + return (-1); + } + return (args[4]); +} + +static int +ofw_close(ofwh_t devh) +{ + ofwcell_t args[] = { + (ofwcell_t)"close", + 1, + 0, + (u_ofwh_t)devh + }; + + if ((*ofw)(args)) { + printf("ofw_close: devh=0x%x\n", devh); + return (1); + } + return (0); +} + +static int +ofw_claim(void *virt, size_t len, u_int align) +{ + ofwcell_t args[] = { + (ofwcell_t)"claim", + 3, + 1, + (ofwcell_t)virt, + len, + align, + 0, + 0 + }; + + if ((*ofw)(args)) { + printf("ofw_claim: virt=%p len=%u\n", virt, len); + return (1); + } + + return (0); +} + +static int +ofw_read(ofwh_t devh, void *buf, size_t len) +{ + ofwcell_t args[] = { + (ofwcell_t)"read", + 3, + 1, + (u_ofwh_t)devh, + (ofwcell_t)buf, + len, + 0 + }; + + if ((*ofw)(args)) { + printf("ofw_read: devh=0x%x buf=%p len=%u\n", devh, buf, len); + return (1); + } + return (0); +} + +static int +ofw_write(ofwh_t devh, const void *buf, size_t len) +{ + ofwcell_t args[] = { + (ofwcell_t)"write", + 3, + 1, + (u_ofwh_t)devh, + (ofwcell_t)buf, + len, + 0 + }; + + if ((*ofw)(args)) { + printf("ofw_write: devh=0x%x buf=%p len=%u\n", devh, buf, len); + return (1); + } + return (0); +} + +static int +ofw_seek(ofwh_t devh, u_int64_t off) +{ + ofwcell_t args[] = { + (ofwcell_t)"seek", + 3, + 1, + (u_ofwh_t)devh, + off >> 32, + off, + 0 + }; + + if ((*ofw)(args)) { + printf("ofw_seek: devh=0x%x off=0x%lx\n", devh, off); + return (1); + } + return (0); +} + +static void +ofw_exit(void) +{ + ofwcell_t args[3]; + + args[0] = (ofwcell_t)"exit"; + args[1] = 0; + args[2] = 0; + + for (;;) + (*ofw)(args); +} + +static void +bcopy(const void *src, void *dst, size_t len) +{ + const char *s = src; + char *d = dst; + + while (len-- != 0) + *d++ = *s++; +} + +static void +memcpy(void *dst, const void *src, size_t len) +{ + bcopy(src, dst, len); +} + +static void +bzero(void *b, size_t len) +{ + char *p = b; + + while (len-- != 0) + *p++ = 0; +} + +static int +strcmp(const char *s1, const char *s2) +{ + for (; *s1 == *s2 && *s1; s1++, s2++) + ; + return ((u_char)*s1 - (u_char)*s2); +} + +#include "ufsread.c" + +int +main(int ac, char **av) +{ + const char *path; + char bootpath_full[255]; + int i, len; + + path = _PATH_LOADER; + for (i = 0; i < ac; i++) { + switch (av[i][0]) { + case '-': + switch (av[i][1]) { + default: + usage(); + } + break; + default: + path = av[i]; + break; + } + } + + printf(" \n>> FreeBSD/powerpc Open Firmware boot block\n" + " Boot path: %s\n" + " Boot loader: %s\n", bootpath, path); + + len = 0; + while (bootpath[len] != '\0') len++; + + memcpy(bootpath_full,bootpath,len+1); + + if (bootpath_full[len-1] == ':') { + for (i = 0; i < 16; i++) { + if (i < 10) { + bootpath_full[len] = i + '0'; + bootpath_full[len+1] = '\0'; + } else { + bootpath_full[len] = '1'; + bootpath_full[len+1] = i - 10 + '0'; + bootpath_full[len+2] = '\0'; + } + + if (mount(bootpath_full,1) >= 0) + break; + + if (bootdev > 0) + ofw_close(bootdev); + } + + if (i >= 16) + panic("mount"); + } else { + if (mount(bootpath_full,0) == -1) + panic("mount"); + } + + printf(" Boot volume: %s\n",bootpath_full); + ofw_setprop(chosenh, "bootargs", bootpath_full, len+2); + load(path); + return (1); +} + +static void +usage(void) +{ + + printf("usage: boot device [/path/to/loader]\n"); + exit(1); +} + +static void +exit(int code) +{ + + ofw_exit(); +} + +static struct dmadat __dmadat; + +static int +mount(const char *device, int quiet) +{ + + dmadat = &__dmadat; + if ((bootdev = ofw_open(device)) == -1) { + printf("mount: can't open device\n"); + return (-1); + } + if (fsread(0, NULL, 0)) { + if (!quiet) + printf("mount: can't read superblock\n"); + return (-1); + } + return (0); +} + +static void +load(const char *fname) +{ + Elf32_Ehdr eh; + Elf32_Phdr ph; + caddr_t p; + ino_t ino; + int i; + + if ((ino = lookup(fname)) == 0) { + printf("File %s not found\n", fname); + return; + } + if (fsread(ino, &eh, sizeof(eh)) != sizeof(eh)) { + printf("Can't read elf header\n"); + return; + } + if (!IS_ELF(eh)) { + printf("Not an ELF file\n"); + return; + } + for (i = 0; i < eh.e_phnum; i++) { + fs_off = eh.e_phoff + i * eh.e_phentsize; + if (fsread(ino, &ph, sizeof(ph)) != sizeof(ph)) { + printf("Can't read program header %d\n", i); + return; + } + if (ph.p_type != PT_LOAD) + continue; + fs_off = ph.p_offset; + p = (caddr_t)ph.p_vaddr; + ofw_claim(p,(ph.p_filesz > ph.p_memsz) ? + ph.p_filesz : ph.p_memsz,0); + if (fsread(ino, p, ph.p_filesz) != ph.p_filesz) { + printf("Can't read content of section %d\n", i); + return; + } + if (ph.p_filesz != ph.p_memsz) + bzero(p + ph.p_filesz, ph.p_memsz - ph.p_filesz); + } + ofw_close(bootdev); + (*(void (*)(void *, int, ofwfp_t, char *, int))eh.e_entry)(NULL, 0, + ofw,NULL,0); +} + +static int +dskread(void *buf, u_int64_t lba, int nblk) +{ + /* + * The Open Firmware should open the correct partition for us. + * That means, if we read from offset zero on an open instance handle, + * we should read from offset zero of that partition. + */ + ofw_seek(bootdev, lba * DEV_BSIZE); + ofw_read(bootdev, buf, nblk * DEV_BSIZE); + return (0); +} + +static void +panic(const char *fmt, ...) +{ + char buf[128]; + va_list ap; + + va_start(ap, fmt); + vsnprintf(buf, sizeof buf, fmt, ap); + printf("panic: %s\n", buf); + va_end(ap); + + exit(1); +} + +static int +printf(const char *fmt, ...) +{ + va_list ap; + int ret; + + va_start(ap, fmt); + ret = vprintf(fmt, ap); + va_end(ap); + return (ret); +} + +static int +putchar(char c, void *arg) +{ + char buf; + + if (c == '\n') { + buf = '\r'; + ofw_write(stdouth, &buf, 1); + } + buf = c; + ofw_write(stdouth, &buf, 1); + return (1); +} + +static int +vprintf(const char *fmt, va_list ap) +{ + int ret; + + ret = __printf(fmt, putchar, 0, ap); + return (ret); +} + +static int +vsnprintf(char *str, size_t sz, const char *fmt, va_list ap) +{ + struct sp_data sp; + int ret; + + sp.sp_buf = str; + sp.sp_len = 0; + sp.sp_size = sz; + ret = __printf(fmt, __sputc, &sp, ap); + return (ret); +} + +static int +__printf(const char *fmt, putc_func_t *putc, void *arg, va_list ap) +{ + char buf[(sizeof(long) * 8) + 1]; + char *nbuf; + u_long ul; + u_int ui; + int lflag; + int sflag; + char *s; + int pad; + int ret; + int c; + + nbuf = &buf[sizeof buf - 1]; + ret = 0; + while ((c = *fmt++) != 0) { + if (c != '%') { + ret += putc(c, arg); + continue; + } + lflag = 0; + sflag = 0; + pad = 0; +reswitch: c = *fmt++; + switch (c) { + case '#': + sflag = 1; + goto reswitch; + case '%': + ret += putc('%', arg); + break; + case 'c': + c = va_arg(ap, int); + ret += putc(c, arg); + break; + case 'd': + if (lflag == 0) { + ui = (u_int)va_arg(ap, int); + if (ui < (int)ui) { + ui = -ui; + ret += putc('-', arg); + } + s = __uitoa(nbuf, ui, 10); + } else { + ul = (u_long)va_arg(ap, long); + if (ul < (long)ul) { + ul = -ul; + ret += putc('-', arg); + } + s = __ultoa(nbuf, ul, 10); + } + ret += __puts(s, putc, arg); + break; + case 'l': + lflag = 1; + goto reswitch; + case 'o': + if (lflag == 0) { + ui = (u_int)va_arg(ap, u_int); + s = __uitoa(nbuf, ui, 8); + } else { + ul = (u_long)va_arg(ap, u_long); + s = __ultoa(nbuf, ul, 8); + } + ret += __puts(s, putc, arg); + break; + case 'p': + ul = (u_long)va_arg(ap, void *); + s = __ultoa(nbuf, ul, 16); + ret += __puts("0x", putc, arg); + ret += __puts(s, putc, arg); + break; + case 's': + s = va_arg(ap, char *); + ret += __puts(s, putc, arg); + break; + case 'u': + if (lflag == 0) { + ui = va_arg(ap, u_int); + s = __uitoa(nbuf, ui, 10); + } else { + ul = va_arg(ap, u_long); + s = __ultoa(nbuf, ul, 10); + } + ret += __puts(s, putc, arg); + break; + case 'x': + if (lflag == 0) { + ui = va_arg(ap, u_int); + s = __uitoa(nbuf, ui, 16); + } else { + ul = va_arg(ap, u_long); + s = __ultoa(nbuf, ul, 16); + } + if (sflag) + ret += __puts("0x", putc, arg); + ret += __puts(s, putc, arg); + break; + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + pad = pad * 10 + c - '0'; + goto reswitch; + default: + break; + } + } + return (ret); +} + +static int +__sputc(char c, void *arg) +{ + struct sp_data *sp; + + sp = arg; + if (sp->sp_len < sp->sp_size) + sp->sp_buf[sp->sp_len++] = c; + sp->sp_buf[sp->sp_len] = '\0'; + return (1); +} + +static int +__puts(const char *s, putc_func_t *putc, void *arg) +{ + const char *p; + int ret; + + ret = 0; + for (p = s; *p != '\0'; p++) + ret += putc(*p, arg); + return (ret); +} + +static char * +__uitoa(char *buf, u_int ui, int base) +{ + char *p; + + p = buf; + *p = '\0'; + do + *--p = digits[ui % base]; + while ((ui /= base) != 0); + return (p); +} + +static char * +__ultoa(char *buf, u_long ul, int base) +{ + char *p; + + p = buf; + *p = '\0'; + do + *--p = digits[ul % base]; + while ((ul /= base) != 0); + return (p); +} Added: head/sys/boot/powerpc/boot1.chrp/bootinfo.txt ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/powerpc/boot1.chrp/bootinfo.txt Tue Oct 14 03:32:41 2008 (r183863) @@ -0,0 +1,13 @@ + +FreeBSD/powerpc bootloader +FreeBSD + $FreeBSD$ + + +MacRISC MacRISC3 MacRISC4 + + +boot &device;:&partition;,\ppc\boot1.elf + + + Added: head/sys/boot/powerpc/boot1.chrp/generate-hfs.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/powerpc/boot1.chrp/generate-hfs.sh Tue Oct 14 03:32:41 2008 (r183863) @@ -0,0 +1,64 @@ +#!/bin/sh + +# This script generates the dummy HFS filesystem used for the PowerPC boot +# blocks. It uses hfsutils (emulators/hfsutils) to generate a template +# filesystem with the relevant interesting files. These are then found by +# grep, and the offsets written to a Makefile snippet. +# +# Because of licensing concerns, and because it is overkill, we do not +# distribute hfsutils as a build tool. If you need to regenerate the HFS +# template (e.g. because the boot block or the CHRP script have grown), +# you must install it from ports. + +# $FreeBSD$ + +HFS_SIZE=1600 #Size in 512-byte blocks of the produced image + +CHRPBOOT_SIZE=2k +BOOT1_SIZE=30k + +# Generate 800K HFS image +OUTPUT_FILE=hfs.tmpl + +dd if=/dev/zero of=$OUTPUT_FILE bs=512 count=$HFS_SIZE +hformat -l "FreeBSD Bootstrap" $OUTPUT_FILE +hmount $OUTPUT_FILE + +# Create and bless a directory for the boot loader +hmkdir ppc +hattrib -b ppc +hcd ppc + +# Make two dummy files for the the CHRP boot script and boot1 +echo 'Bootinfo START' | dd of=bootinfo.txt.tmp cbs=$CHRPBOOT_SIZE count=1 conv=block +echo 'Boot1 START' | dd of=boot1.elf.tmp cbs=$BOOT1_SIZE count=1 conv=block + +hcopy boot1.elf.tmp :boot1.elf +hcopy bootinfo.txt.tmp :bootinfo.txt +hattrib -c chrp -t tbxi bootinfo.txt +humount + +rm bootinfo.txt.tmp +rm boot1.elf.tmp + +# Locate the offsets of the two fake files +BOOTINFO_OFFSET=$(hd $OUTPUT_FILE | grep 'Bootinfo START' | cut -f 1 -d ' ') +BOOT1_OFFSET=$(hd $OUTPUT_FILE | grep 'Boot1 START' | cut -f 1 -d ' ') + +# Convert to numbers of blocks +BOOTINFO_OFFSET=$(echo 0x$BOOTINFO_OFFSET | awk '{printf("%x\n",$1/512);}') +BOOT1_OFFSET=$(echo 0x$BOOT1_OFFSET | awk '{printf("%x\n",$1/512);}') + +echo '# This file autogenerated by generate-hfs.sh - DO NOT EDIT' > Makefile.hfs +echo '# $FreeBSD$' >> Makefile.hfs +echo "BOOTINFO_OFFSET=0x$BOOTINFO_OFFSET" >> Makefile.hfs +echo "BOOT1_OFFSET=0x$BOOT1_OFFSET" >> Makefile.hfs + +bzip2 $OUTPUT_FILE +echo 'HFS template boot filesystem created by generate-hfs.sh' > $OUTPUT_FILE.bz2.uu +echo 'DO NOT EDIT' >> $OUTPUT_FILE.bz2.uu +echo '$FreeBSD$' >> $OUTPUT_FILE.bz2.uu + +uuencode $OUTPUT_FILE.bz2 $OUTPUT_FILE.bz2 >> $OUTPUT_FILE.bz2.uu +rm $OUTPUT_FILE.bz2 + Added: head/sys/boot/powerpc/boot1.chrp/hfs.tmpl.bz2.uu ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/boot/powerpc/boot1.chrp/hfs.tmpl.bz2.uu Tue Oct 14 03:32:41 2008 (r183863) @@ -0,0 +1,18 @@ +HFS template boot filesystem created by generate-hfs.sh +DO NOT EDIT +$FreeBSD$ +begin 644 hfs.tmpl.bz2 +M0EIH.3%!62936?(HJX\``"]_]?___O)20>!4M2$>0#MUW$1$``$!$``"2!`( +M4EG``>G*VV3"22334_2(/*>ID,@``:#U&"-#(!IZ0`)$HIY0>B-#(/4T```& +M@R:`&@``<:,F1A&(!A-!@$T&@9,FC)D,(#!4E-*--31ZAB!DT!ID:#$81HT& +M@9-!Z::C:E=SZCC1((92M^1Q@3&>="[<2FD((A[AT#`[('#?MSV(S,>HOI'#2,"EJ0PU5).T`PX,54O,RTW8-",N1`R>?SL"+?Q51[H]# +MJ1C5"]BDBF1UJ!Y`J$WTC]QAFZ%Q21$J,I&0,0?9?DPU!Z>$9.380JJCO$Q8 +MXZTX)GQCCGNC%G1BIDBHTK#J9N0,M[85QC:.'>]#,GPRAALU*=)2`$ND22<. +-VK/^+N2*<*$AY%%7'@`` +` +end From edwin at FreeBSD.org Tue Oct 14 03:38:03 2008 From: edwin at FreeBSD.org (Edwin Groothuis) Date: Tue Oct 14 03:38:15 2008 Subject: svn commit: r183864 - head/share/zoneinfo Message-ID: <200810140338.m9E3c2b4094519@svn.freebsd.org> Author: edwin Date: Tue Oct 14 03:38:02 2008 New Revision: 183864 URL: http://svn.freebsd.org/changeset/base/183864 Log: MFV of r183861: Vendor import of tzdata2008h - Minor update for Mauritius (which I don't understand) - Syria goes to DST at 1 November instead of 1 October. - Niue is now located at the right side of the equator. Modified: head/share/zoneinfo/ (props changed) head/share/zoneinfo/africa head/share/zoneinfo/asia head/share/zoneinfo/southamerica head/share/zoneinfo/zone.tab Modified: head/share/zoneinfo/africa ============================================================================== --- head/share/zoneinfo/africa Tue Oct 14 03:32:41 2008 (r183863) +++ head/share/zoneinfo/africa Tue Oct 14 03:38:02 2008 (r183864) @@ -1,4 +1,4 @@ -# @(#)africa 8.16 +# @(#)africa 8.17 #
 
 # This data is by no means authoritative; if you think you know better,
@@ -453,11 +453,19 @@ Zone Africa/Nouakchott	-1:03:48 -	LMT	19
 # year 2008 - 2009 will, therefore, be effective as from 26 October 2008
 # and end on 29 March 2009.
 
+# From Ed Maste (2008-10-07):
+# THE TIME BILL (No. XXVII of 2008) Explanatory Memorandum states the
+# beginning / ending of summer time is 2 o'clock standard time in the
+# morning of the last Sunday of October / last Sunday of March.
+# 
+# http://www.gov.mu/portal/goc/assemblysite/file/bill2708.pdf
+# 
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule Mauritius	1982	only	-	Oct	10	0:00	1:00	S
 Rule Mauritius	1983	only	-	Mar	21	0:00	0	-
-Rule Mauritius	2008	max	-	Oct	lastSun	2:00	1:00	S
-Rule Mauritius	2009	max	-	Mar	lastSun	2:00	0	-
+Rule Mauritius	2008	max	-	Oct	lastSun	2:00s	1:00	S
+Rule Mauritius	2009	max	-	Mar	lastSun	2:00s	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Indian/Mauritius	3:50:00 -	LMT	1907		# Port Louis
 			4:00 Mauritius	MU%sT	# Mauritius Time

Modified: head/share/zoneinfo/asia
==============================================================================
--- head/share/zoneinfo/asia	Tue Oct 14 03:32:41 2008	(r183863)
+++ head/share/zoneinfo/asia	Tue Oct 14 03:38:02 2008	(r183864)
@@ -1,4 +1,4 @@
-# @(#)asia	8.23
+# @(#)asia	8.24
 # 
 
 # This data is by no means authoritative; if you think you know better,
@@ -1957,8 +1957,20 @@ Rule	Syria	2007	only	-	Nov	 Fri>=1	0:00	
 # compilers can't handle  or having multiple Rules (a la Israel).
 # For now, use "Apr Fri>=1", and go with IATA on a uniform Sep 30 end.
 
+# From Steffen Thorsen (2008-10-07):
+# Syria has now officially decided to end DST on 2008-11-01 this year,
+# according to the following article in the Syrian Arab News Agency (SANA).
+#
+# The article is in Arabic, and seems to tell that they will go back to
+# winter time on 2008-11-01 at 00:00 local daylight time (delaying/setting
+# clocks back 60 minutes).
+#
+# 
+# http://sana.sy/ara/2/2008/10/07/195459.htm
+# 
+
 Rule	Syria	2008	max	-	Apr	Fri>=1	0:00	1:00	S
-Rule	Syria	2008	max	-	Oct	1	0:00	0	-
+Rule	Syria	2008	max	-	Nov	1	0:00	0	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Damascus	2:25:12 -	LMT	1920	# Dimashq

Modified: head/share/zoneinfo/southamerica
==============================================================================
--- head/share/zoneinfo/southamerica	Tue Oct 14 03:32:41 2008	(r183863)
+++ head/share/zoneinfo/southamerica	Tue Oct 14 03:38:02 2008	(r183864)
@@ -1,4 +1,4 @@
-# @(#)southamerica	8.29
+# @(#)southamerica	8.30
 # 
 
 # This data is by no means authoritative; if you think you know better,
@@ -177,6 +177,22 @@ Rule	Arg	2000	only	-	Mar	3	0:00	0	-
 # http://www.impulsobaires.com.ar/nota.php?id=57832 (in spanish)
 # 
 
+# From Rodrigo Severo (2008-10-06):
+# Here is some info available at a Gentoo bug related to TZ on Argentina's DST:
+# ...
+# ------- Comment #1 from [jmdocile]  2008-10-06 16:28 0000 -------
+# Hi, there is a problem with timezone-data-2008e and maybe with
+# timezone-data-2008f
+# Argentinian law [Number] 25.155 is no longer valid.
+# 
+# http://www.infoleg.gov.ar/infolegInternet/anexos/60000-64999/60036/norma.htm
+# 
+# The new one is law [Number] 26.350
+# 
+# http://www.infoleg.gov.ar/infolegInternet/anexos/135000-139999/136191/norma.htm
+# 
+# So there is no summer time in Argentina for now.
+
 Rule	Arg	2007	only	-	Dec	30	0:00	1:00	S
 Rule	Arg	2008	max	-	Mar	Sun>=15	0:00	0	-
 Rule	Arg	2008	max	-	Oct	Sun>=15	0:00	1:00	S

Modified: head/share/zoneinfo/zone.tab
==============================================================================
--- head/share/zoneinfo/zone.tab	Tue Oct 14 03:32:41 2008	(r183863)
+++ head/share/zoneinfo/zone.tab	Tue Oct 14 03:38:02 2008	(r183864)
@@ -1,4 +1,4 @@
-# @(#)zone.tab	8.18
+# @(#)zone.tab	8.19
 #
 # TZ zone descriptions
 #
@@ -293,7 +293,7 @@ NL	+5222+00454	Europe/Amsterdam
 NO	+5955+01045	Europe/Oslo
 NP	+2743+08519	Asia/Katmandu
 NR	-0031+16655	Pacific/Nauru
-NU	-1901+16955	Pacific/Niue
+NU	-1901-16955	Pacific/Niue
 NZ	-3652+17446	Pacific/Auckland	most locations
 NZ	-4357-17633	Pacific/Chatham	Chatham Islands
 OM	+2336+05835	Asia/Muscat
From edwin at FreeBSD.org  Tue Oct 14 04:09:34 2008
From: edwin at FreeBSD.org (Edwin Groothuis)
Date: Tue Oct 14 04:09:40 2008
Subject: svn commit: r183865 - head/share/zoneinfo
Message-ID: <200810140409.m9E49XFn095103@svn.freebsd.org>

Author: edwin
Date: Tue Oct 14 04:09:33 2008
New Revision: 183865
URL: http://svn.freebsd.org/changeset/base/183865

Log:
  update the manual on how to import and MFV new tzdata releases

Modified:
  head/share/zoneinfo/Makefile

Modified: head/share/zoneinfo/Makefile
==============================================================================
--- head/share/zoneinfo/Makefile	Tue Oct 14 03:38:02 2008	(r183864)
+++ head/share/zoneinfo/Makefile	Tue Oct 14 04:09:33 2008	(r183865)
@@ -17,17 +17,15 @@
 # $ cd ~/svn/vendor/tzdata
 # $ svn cp svn+ssh://svn.freebsd.org/base/vendor/tzdata/dist \
 #	svn+ssh://svn.freebsd.org/base/vendor/tzdata/tzdata2008X
-# $ svn update
+# $ svn update	# Commit message: "Tag of tzdata2008X"
 #
 # Merge-from-vendor
 #
-# $ cd ~svn/head/share/zoneinfo
+# $ cd ~/svn/head/share/zoneinfo
 # $ svn update
-# $ svn merge --accept=postpone \
+# $ svn merge -c X --accept=postpone \
 #	svn+ssh://svn.freebsd.org/base/vendor/tzdata/dist .
-# $ svn diff --no-diff-deleted \
-#	--old=svn+ssh://svn.freebsd.org/base/vendor/tzdata/dist --new=.
-# $ svn commit
+# $ svn update	# Commit message: "MFV of tzdata2008X"
 #
 
 CLEANFILES+=	yearistype
From raj at FreeBSD.org  Tue Oct 14 07:05:21 2008
From: raj at FreeBSD.org (Rafal Jaworowski)
Date: Tue Oct 14 07:05:27 2008
Subject: svn commit: r183866 - head/sys/dev/usb
Message-ID: <200810140705.m9E75K3x098307@svn.freebsd.org>

Author: raj
Date: Tue Oct 14 07:05:20 2008
New Revision: 183866
URL: http://svn.freebsd.org/changeset/base/183866

Log:
  Mbus attachment for USB EHCI integrated controller on Marvell chips.
  
  This includes workarounds required for the ehci(4) to handle some non-standard
  behaviour of these devices.
  
  Obtained from:	Marvell, Semihalf

Added:
  head/sys/dev/usb/ehci_mbus.c   (contents, props changed)
Modified:
  head/sys/dev/usb/ehci.c
  head/sys/dev/usb/ehcivar.h

Modified: head/sys/dev/usb/ehci.c
==============================================================================
--- head/sys/dev/usb/ehci.c	Tue Oct 14 04:09:33 2008	(r183865)
+++ head/sys/dev/usb/ehci.c	Tue Oct 14 07:05:20 2008	(r183866)
@@ -351,8 +351,12 @@ ehci_hcreset(ehci_softc_t *sc)
 	for (i = 0; i < 100; i++) {
 		usb_delay_ms(&sc->sc_bus, 1);
 		hcr = EOREAD4(sc, EHCI_USBCMD) & EHCI_CMD_HCRESET;
-		if (!hcr)
+		if (!hcr) {
+			if (sc->sc_flags & EHCI_SCFLG_SETMODE)
+				EOWRITE4(sc,  0x68, 0x3);
+
 			return (USBD_NORMAL_COMPLETION);
+		}
 	}
 	printf("%s: reset timeout\n", device_get_nameunit(sc->sc_bus.bdev));
 	return (USBD_IOERROR);
@@ -2194,7 +2198,18 @@ ehci_root_ctrl_start(usbd_xfer_handle xf
 		v = EOREAD4(sc, EHCI_PORTSC(index));
 		DPRINTFN(8,("ehci_root_ctrl_start: port status=0x%04x\n",
 			    v));
+
 		i = UPS_HIGH_SPEED;
+
+		if (sc->sc_flags & EHCI_SCFLG_FORCESPEED) {
+			if ((v & 0xc000000) == 0x8000000)
+				i = UPS_HIGH_SPEED;
+			else if ((v & 0xc000000) == 0x4000000)
+				i = UPS_LOW_SPEED;
+			else
+				i = 0;
+		}
+
 		if (v & EHCI_PS_CS)	i |= UPS_CURRENT_CONNECT_STATUS;
 		if (v & EHCI_PS_PE)	i |= UPS_PORT_ENABLED;
 		if (v & EHCI_PS_SUSP)	i |= UPS_SUSPEND;
@@ -2249,7 +2264,11 @@ ehci_root_ctrl_start(usbd_xfer_handle xf
 				goto ret;
 			}
 			/* Terminate reset sequence. */
-			EOWRITE4(sc, port, v);
+			if (sc->sc_flags & EHCI_SCFLG_NORESTERM)
+				;
+			else
+				EOWRITE4(sc, port, v);
+
 			/* Wait for HC to complete reset. */
 			usb_delay_ms(&sc->sc_bus, EHCI_PORT_RESET_COMPLETE);
 			if (sc->sc_dying) {

Added: head/sys/dev/usb/ehci_mbus.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/usb/ehci_mbus.c	Tue Oct 14 07:05:20 2008	(r183866)
@@ -0,0 +1,318 @@
+/*-
+ * Copyright (C) 2008 MARVELL INTERNATIONAL LTD.
+ * All rights reserved.
+ *
+ * Developed by Semihalf.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of MARVELL nor the names of contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * MBus attachment driver for the USB Enhanced Host Controller.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include "opt_bus.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+#define EHCI_VENDORID_MRVL	0x1286
+#define EHCI_HC_DEVSTR		"Marvell Integrated USB 2.0 controller"
+
+static device_attach_t ehci_mbus_attach;
+static device_detach_t ehci_mbus_detach;
+static device_shutdown_t ehci_mbus_shutdown;
+static device_suspend_t ehci_mbus_suspend;
+static device_resume_t ehci_mbus_resume;
+
+static int
+ehci_mbus_suspend(device_t self)
+{
+	ehci_softc_t *sc;
+	int err;
+
+	err = bus_generic_suspend(self);
+	if (err)
+		return (err);
+
+	sc = device_get_softc(self);
+	ehci_power(PWR_SUSPEND, sc);
+
+	return (0);
+}
+
+static int
+ehci_mbus_resume(device_t self)
+{
+	ehci_softc_t *sc;
+
+	sc = device_get_softc(self);
+
+	ehci_power(PWR_RESUME, sc);
+	bus_generic_resume(self);
+
+	return (0);
+}
+
+static int
+ehci_mbus_shutdown(device_t self)
+{
+	ehci_softc_t *sc;
+	int err;
+
+	err = bus_generic_shutdown(self);
+	if (err)
+		return (err);
+
+	sc = device_get_softc(self);
+	ehci_shutdown(sc);
+
+	return (0);
+}
+
+static int
+ehci_mbus_probe(device_t self)
+{
+
+	device_set_desc(self, EHCI_HC_DEVSTR);
+
+	return (BUS_PROBE_DEFAULT);
+}
+
+static int
+ehci_mbus_attach(device_t self)
+{
+	ehci_softc_t *sc;
+	bus_space_handle_t bsh;
+	int err, rid;
+
+	sc = device_get_softc(self);
+	sc->sc_bus.usbrev = USBREV_2_0;
+
+	rid = 0;
+	sc->io_res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid, RF_ACTIVE);
+	if (!sc->io_res) {
+		device_printf(self, "Could not map memory\n");
+		return (ENXIO);
+	}
+	sc->iot = rman_get_bustag(sc->io_res);
+	bsh = rman_get_bushandle(sc->io_res);
+
+	/*
+	 * Marvell EHCI host controller registers start at certain offset within
+	 * the whole USB registers range, so create a subregion for the host
+	 * mode configuration purposes.
+	 */
+	if (bus_space_subregion(sc->iot, bsh, MV_USB_HOST_OFST,
+	    MV_USB_SIZE - MV_USB_HOST_OFST, &sc->ioh) != 0)
+		panic("%s: unable to subregion USB host registers",
+		    device_get_name(self));
+	sc->sc_size = MV_USB_SIZE - MV_USB_HOST_OFST;
+
+	/*
+	 * Notice: Marvell EHCI controller has TWO interrupt lines, so make sure to
+	 * use the correct rid for the main one (controller interrupt) --
+	 * refer to obio_devices[] for the right resource number to use here.
+	 */
+	rid = 1;
+	sc->irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid,
+	    RF_SHAREABLE | RF_ACTIVE);
+	if (sc->irq_res == NULL) {
+		device_printf(self, "Could not allocate irq\n");
+		ehci_mbus_detach(self);
+		return (ENXIO);
+	}
+	sc->sc_bus.bdev = device_add_child(self, "usb", -1);
+	if (!sc->sc_bus.bdev) {
+		device_printf(self, "Could not add USB device\n");
+		ehci_mbus_detach(self);
+		return (ENOMEM);
+	}
+	device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus);
+
+	sprintf(sc->sc_vendor, "Marvell");
+	sc->sc_id_vendor = EHCI_VENDORID_MRVL;
+
+	err = bus_setup_intr(self, sc->irq_res, INTR_TYPE_BIO,
+	    NULL, (driver_intr_t*)ehci_intr, sc, &sc->ih);
+	if (err) {
+		device_printf(self, "Could not setup irq, %d\n", err);
+		sc->ih = NULL;
+		ehci_mbus_detach(self);
+		return (ENXIO);
+	}
+
+	/* There are no companion USB controllers */
+	sc->sc_ncomp = 0;
+
+	/* Allocate a parent dma tag for DMA maps */
+	err = bus_dma_tag_create(bus_get_dma_tag(self), 1, 0,
+	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
+	    BUS_SPACE_MAXSIZE_32BIT, USB_DMA_NSEG, BUS_SPACE_MAXSIZE_32BIT, 0,
+	    NULL, NULL, &sc->sc_bus.parent_dmatag);
+	if (err) {
+		device_printf(self, "Could not allocate parent DMA tag (%d)\n",
+		    err);
+		ehci_mbus_detach(self);
+		return (ENXIO);
+	}
+
+	/* Allocate a dma tag for transfer buffers */
+	err = bus_dma_tag_create(sc->sc_bus.parent_dmatag, 1, 0,
+	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
+	    BUS_SPACE_MAXSIZE_32BIT, USB_DMA_NSEG, BUS_SPACE_MAXSIZE_32BIT, 0,
+	    busdma_lock_mutex, &Giant, &sc->sc_bus.buffer_dmatag);
+	if (err) {
+		device_printf(self, "Could not allocate buffer DMA tag (%d)\n",
+		    err);
+		ehci_mbus_detach(self);
+		return (ENXIO);
+	}
+
+	/*
+	 * Workaround for Marvell integrated EHCI controller: reset of
+	 * the EHCI core clears the USBMODE register, which sets the core in
+	 * an undefined state (neither host nor agent), so it needs to be set
+	 * again for proper operation.
+	 *
+	 * Refer to errata document MV-S500832-00D.pdf (p. 5.24 GL USB-2) for
+	 * details.
+	 */
+	sc->sc_flags |= EHCI_SCFLG_SETMODE;
+	if (bootverbose)
+		device_printf(self, "5.24 GL USB-2 workaround enabled\n");
+
+	/* XXX all MV chips need it? */
+	sc->sc_flags |= EHCI_SCFLG_FORCESPEED | EHCI_SCFLG_NORESTERM;
+
+	err = ehci_init(sc);
+	if (!err) {
+		sc->sc_flags |= EHCI_SCFLG_DONEINIT;
+		err = device_probe_and_attach(sc->sc_bus.bdev);
+	}
+
+	if (err) {
+		device_printf(self, "USB init failed err=%d\n", err);
+		ehci_mbus_detach(self);
+		return (EIO);
+	}
+	return (0);
+}
+
+static int
+ehci_mbus_detach(device_t self)
+{
+	ehci_softc_t *sc;
+	int err;
+
+	sc = device_get_softc(self);
+	if (sc->sc_flags & EHCI_SCFLG_DONEINIT) {
+		ehci_detach(sc, 0);
+		sc->sc_flags &= ~EHCI_SCFLG_DONEINIT;
+	}
+
+	/*
+	 * Disable interrupts that might have been switched on in ehci_init()
+	 */
+	if (sc->iot && sc->ioh)
+		bus_space_write_4(sc->iot, sc->ioh, EHCI_USBINTR, 0);
+	if (sc->sc_bus.parent_dmatag != NULL)
+		bus_dma_tag_destroy(sc->sc_bus.parent_dmatag);
+	if (sc->sc_bus.buffer_dmatag != NULL)
+		bus_dma_tag_destroy(sc->sc_bus.buffer_dmatag);
+
+	if (sc->irq_res && sc->ih) {
+		err = bus_teardown_intr(self, sc->irq_res, sc->ih);
+
+		if (err)
+			device_printf(self, "Could not tear down irq, %d\n",
+			    err);
+		sc->ih = NULL;
+	}
+	if (sc->sc_bus.bdev) {
+		device_delete_child(self, sc->sc_bus.bdev);
+		sc->sc_bus.bdev = NULL;
+	}
+	if (sc->irq_res) {
+		bus_release_resource(self, SYS_RES_IRQ, 0, sc->irq_res);
+		sc->irq_res = NULL;
+	}
+	if (sc->io_res) {
+		bus_release_resource(self, SYS_RES_MEMORY, 0, sc->io_res);
+		sc->io_res = NULL;
+		sc->iot = 0;
+		sc->ioh = 0;
+	}
+	return (0);
+}
+
+static device_method_t ehci_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_probe, ehci_mbus_probe),
+	DEVMETHOD(device_attach, ehci_mbus_attach),
+	DEVMETHOD(device_detach, ehci_mbus_detach),
+	DEVMETHOD(device_suspend, ehci_mbus_suspend),
+	DEVMETHOD(device_resume, ehci_mbus_resume),
+	DEVMETHOD(device_shutdown, ehci_mbus_shutdown),
+
+	/* Bus interface */
+	DEVMETHOD(bus_print_child, bus_generic_print_child),
+
+	{0, 0}
+};
+
+static driver_t ehci_driver = {
+	"ehci",
+	ehci_methods,
+	sizeof(ehci_softc_t),
+};
+
+static devclass_t ehci_devclass;
+
+DRIVER_MODULE(ehci, mbus, ehci_driver, ehci_devclass, 0, 0);

Modified: head/sys/dev/usb/ehcivar.h
==============================================================================
--- head/sys/dev/usb/ehcivar.h	Tue Oct 14 04:09:33 2008	(r183865)
+++ head/sys/dev/usb/ehcivar.h	Tue Oct 14 07:05:20 2008	(r183866)
@@ -122,6 +122,9 @@ struct ehci_soft_islot {
 
 #define EHCI_SCFLG_DONEINIT	0x0001	/* ehci_init() has been called. */
 #define EHCI_SCFLG_LOSTINTRBUG	0x0002	/* workaround for VIA / ATI chipsets */
+#define EHCI_SCFLG_SETMODE	0x0004	/* set bridge mode again after init (Marvell) */
+#define EHCI_SCFLG_FORCESPEED	0x0008	/* force speed (Marvell) */
+#define EHCI_SCFLG_NORESTERM	0x0010	/* don't terminate reset sequence (Marvell) */
 
 typedef struct ehci_softc {
 	struct usbd_bus sc_bus;		/* base device */
From raj at FreeBSD.org  Tue Oct 14 07:24:19 2008
From: raj at FreeBSD.org (Rafal Jaworowski)
Date: Tue Oct 14 07:24:25 2008
Subject: svn commit: r183867 - head/sys/dev/mge
Message-ID: <200810140724.m9E7OJGX098673@svn.freebsd.org>

Author: raj
Date: Tue Oct 14 07:24:18 2008
New Revision: 183867
URL: http://svn.freebsd.org/changeset/base/183867

Log:
  Marvell Gigabit Ethernet controller driver.
  
  This supports 1Gbps Ethernet engine found on ARM-based SOCs (Orion, Kirkwood,
  Discovery), as well as on system controllers for PowerPC processors (MV64430,
  MV6446x).
  
  The following advanced features are supported:
  
    - multicast
    - VLAN tagging
    - IP/TCP/UDP checksum calculation offloading
    - polling
    - interrupt coalescing
  
  Obtained from:	Marvell, Semihalf

Added:
  head/sys/dev/mge/
  head/sys/dev/mge/if_mge.c   (contents, props changed)
  head/sys/dev/mge/if_mgevar.h   (contents, props changed)

Added: head/sys/dev/mge/if_mge.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/dev/mge/if_mge.c	Tue Oct 14 07:24:18 2008	(r183867)
@@ -0,0 +1,1757 @@
+/*-
+ * Copyright (C) 2008 MARVELL INTERNATIONAL LTD.
+ * All rights reserved.
+ *
+ * Developed by Semihalf.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of MARVELL nor the names of contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef HAVE_KERNEL_OPTION_HEADERS
+#include "opt_device_polling.h"
+#endif
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#if defined(SOC_MV_KIRKWOOD) || defined(SOC_MV_DISCOVERY)
+#define  MGE_VER2	1
+#endif
+
+#define	MV_PHY_ADDR_BASE	8
+
+#include 
+#include 
+
+#include "miibus_if.h"
+
+/* PHY registers are in the address space of the first mge unit */
+static struct mge_softc *sc_mge0 = NULL;
+
+static int mge_probe(device_t dev);
+static int mge_attach(device_t dev);
+static int mge_detach(device_t dev);
+static int mge_shutdown(device_t dev);
+static int mge_suspend(device_t dev);
+static int mge_resume(device_t dev);
+
+static int mge_miibus_readreg(device_t dev, int phy, int reg);
+static void mge_miibus_writereg(device_t dev, int phy, int reg, int value);
+
+static int mge_ifmedia_upd(struct ifnet *ifp);
+static void mge_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr);
+
+static void mge_init(void *arg);
+static void mge_init_locked(void *arg);
+static void mge_start(struct ifnet *ifp);
+static void mge_start_locked(struct ifnet *ifp);
+static void mge_watchdog(struct mge_softc *sc);
+static int mge_ioctl(struct ifnet *ifp, u_long command, caddr_t data);
+
+static void mge_intrs_ctrl(struct mge_softc *sc, int enable);
+static void mge_intr_rx(void *arg);
+static void mge_intr_rx_locked(struct mge_softc *sc, int count);
+static void mge_intr_tx(void *arg);
+static void mge_intr_tx_locked(struct mge_softc *sc);
+static void mge_intr_misc(void *arg);
+static void mge_intr_sum(void *arg);
+static void mge_intr_err(void *arg);
+static void mge_stop(struct mge_softc *sc);
+static void mge_tick(void *msc);
+static uint32_t mge_set_port_serial_control(uint32_t media);
+static void mge_get_mac_address(struct mge_softc *sc, uint8_t *addr);
+static void mge_set_mac_address(struct mge_softc *sc);
+static void mge_set_ucast_address(struct mge_softc *sc, uint8_t last_byte,
+    uint8_t queue);
+static void mge_set_prom_mode(struct mge_softc *sc, uint8_t queue);
+static int mge_allocate_dma(struct mge_softc *sc);
+static int mge_alloc_desc_dma(struct mge_softc *sc,
+    struct mge_desc_wrapper* desc_tab, uint32_t size, bus_dma_tag_t *buffer_tag);
+static int mge_new_rxbuf(bus_dma_tag_t tag, bus_dmamap_t map,
+    struct mbuf **mbufp, bus_addr_t *paddr);
+static void mge_get_dma_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error);
+static void mge_free_dma(struct mge_softc *sc);
+static void mge_free_desc(struct mge_softc *sc, struct mge_desc_wrapper* tab, uint32_t size,
+    bus_dma_tag_t buffer_tag, uint8_t free_mbufs);
+static void mge_offload_process_frame(struct ifnet *ifp, struct mbuf *frame,
+    uint32_t status, uint16_t bufsize);
+static void mge_offload_setup_descriptor(struct mge_softc *sc,
+    struct mge_desc_wrapper *dw);
+static uint8_t mge_crc8(uint8_t *data, int size);
+static void mge_setup_multicast(struct mge_softc *sc);
+static void mge_set_rxic(struct mge_softc *sc);
+static void mge_set_txic(struct mge_softc *sc);
+static void mge_add_sysctls(struct mge_softc *sc);
+static int mge_sysctl_ic(SYSCTL_HANDLER_ARGS);
+
+static device_method_t mge_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_probe,		mge_probe),
+	DEVMETHOD(device_attach,	mge_attach),
+	DEVMETHOD(device_detach,	mge_detach),
+	DEVMETHOD(device_shutdown,	mge_shutdown),
+	DEVMETHOD(device_suspend,	mge_suspend),
+	DEVMETHOD(device_resume,	mge_resume),
+	/* MII interface */
+	DEVMETHOD(miibus_readreg,	mge_miibus_readreg),
+	DEVMETHOD(miibus_writereg,	mge_miibus_writereg),
+	{ 0, 0 }
+};
+
+static driver_t mge_driver = {
+	"mge",
+	mge_methods,
+	sizeof(struct mge_softc),
+};
+
+static devclass_t mge_devclass;
+
+DRIVER_MODULE(mge, mbus, mge_driver, mge_devclass, 0, 0);
+DRIVER_MODULE(miibus, mge, miibus_driver, miibus_devclass, 0, 0);
+MODULE_DEPEND(mge, ether, 1, 1, 1);
+MODULE_DEPEND(mge, miibus, 1, 1, 1);
+
+static struct resource_spec res_spec[] = {
+	{ SYS_RES_MEMORY, 0, RF_ACTIVE },
+	{ SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE },
+	{ SYS_RES_IRQ, 1, RF_ACTIVE | RF_SHAREABLE },
+	{ SYS_RES_IRQ, 2, RF_ACTIVE | RF_SHAREABLE },
+	{ SYS_RES_IRQ, 3, RF_ACTIVE | RF_SHAREABLE },
+	{ SYS_RES_IRQ, 4, RF_ACTIVE | RF_SHAREABLE },
+	{ -1, 0 }
+};
+
+static struct {
+	driver_intr_t *handler;
+	char * description;
+} mge_intrs[MGE_INTR_COUNT] = {
+	{ mge_intr_rx,	"GbE receive interrupt" },
+	{ mge_intr_tx,	"GbE transmit interrupt" },
+	{ mge_intr_misc,"GbE misc interrupt" },
+	{ mge_intr_sum,	"GbE summary interrupt" },
+	{ mge_intr_err,	"GbE error interrupt" },
+};
+
+static void
+mge_get_mac_address(struct mge_softc *sc, uint8_t *addr)
+{
+	uint32_t mac_l, mac_h;
+
+	/* XXX use currently programmed MAC address; eventually this info will
+	 * be provided by the loader */
+
+	mac_l = MGE_READ(sc, MGE_MAC_ADDR_L);
+	mac_h = MGE_READ(sc, MGE_MAC_ADDR_H);
+
+	addr[0] = (mac_h & 0xff000000) >> 24;
+	addr[1] = (mac_h & 0x00ff0000) >> 16;
+	addr[2] = (mac_h & 0x0000ff00) >> 8;
+	addr[3] = (mac_h & 0x000000ff);
+	addr[4] = (mac_l & 0x0000ff00) >> 8;
+	addr[5] = (mac_l & 0x000000ff);
+}
+
+static void
+mge_set_mac_address(struct mge_softc *sc)
+{
+	char *if_mac;
+	uint32_t mac_l, mac_h;
+
+	MGE_GLOBAL_LOCK_ASSERT(sc);
+
+	if_mac = (char *)IF_LLADDR(sc->ifp);
+
+	mac_l = (if_mac[4] << 8) | (if_mac[5]);
+	mac_h = (if_mac[0] << 24)| (if_mac[1] << 16) |
+	    (if_mac[2] << 8) | (if_mac[3] << 0);
+
+	MGE_WRITE(sc, MGE_MAC_ADDR_L, mac_l);
+	MGE_WRITE(sc, MGE_MAC_ADDR_H, mac_h);
+
+	mge_set_ucast_address(sc, if_mac[5], MGE_RX_DEFAULT_QUEUE);
+}
+
+static void
+mge_set_ucast_address(struct mge_softc *sc, uint8_t last_byte, uint8_t queue)
+{
+	uint32_t reg_idx, reg_off, reg_val, i;
+
+	last_byte &= 0xf;
+	reg_idx = last_byte / MGE_UCAST_REG_NUMBER;
+	reg_off = (last_byte % MGE_UCAST_REG_NUMBER) * 8;
+	reg_val = (1 | (queue << 1)) << reg_off;
+
+	for (i = 0; i < MGE_UCAST_REG_NUMBER; i++) {
+		if ( i == reg_idx)
+			MGE_WRITE(sc, MGE_DA_FILTER_UCAST(i), reg_val);
+		else
+			MGE_WRITE(sc, MGE_DA_FILTER_UCAST(i), 0);
+	}
+}
+
+static void
+mge_set_prom_mode(struct mge_softc *sc, uint8_t queue)
+{
+	uint32_t port_config;
+	uint32_t reg_val, i;
+
+	/* Enable or disable promiscuous mode as needed */
+	if (sc->ifp->if_flags & IFF_PROMISC) {
+		port_config = MGE_READ(sc, MGE_PORT_CONFIG);
+		port_config |= PORT_CONFIG_UPM;
+		MGE_WRITE(sc, MGE_PORT_CONFIG, port_config);
+
+		reg_val = ((1 | (queue << 1)) | (1 | (queue << 1)) << 8 |
+		   (1 | (queue << 1)) << 16 | (1 | (queue << 1)) << 24);
+
+		for (i = 0; i < MGE_MCAST_REG_NUMBER; i++) {
+			MGE_WRITE(sc, MGE_DA_FILTER_SPEC_MCAST(i), reg_val);
+			MGE_WRITE(sc, MGE_DA_FILTER_OTH_MCAST(i), reg_val);
+		}
+
+		for (i = 0; i < MGE_UCAST_REG_NUMBER; i++)
+			MGE_WRITE(sc, MGE_DA_FILTER_UCAST(i), reg_val);
+
+	} else {
+		port_config = MGE_READ(sc, MGE_PORT_CONFIG);
+		port_config &= ~PORT_CONFIG_UPM;
+		MGE_WRITE(sc, MGE_PORT_CONFIG, port_config);
+
+		for (i = 0; i < MGE_MCAST_REG_NUMBER; i++) {
+			MGE_WRITE(sc, MGE_DA_FILTER_SPEC_MCAST(i), 0);
+			MGE_WRITE(sc, MGE_DA_FILTER_OTH_MCAST(i), 0);
+		}
+
+		mge_set_mac_address(sc);
+	}
+}
+
+static void
+mge_get_dma_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error)
+{
+	u_int32_t *paddr;
+
+	KASSERT(nseg == 1, ("wrong number of segments, should be 1"));
+	paddr = arg;
+
+	*paddr = segs->ds_addr;
+}
+
+static int
+mge_new_rxbuf(bus_dma_tag_t tag, bus_dmamap_t map, struct mbuf **mbufp,
+    bus_addr_t *paddr)
+{
+	struct mbuf *new_mbuf;
+	bus_dma_segment_t seg[1];
+	int error;
+	int nsegs;
+
+	KASSERT(mbufp != NULL, ("NULL mbuf pointer!"));
+
+	new_mbuf = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
+	if (new_mbuf == NULL)
+		return (ENOBUFS);
+	new_mbuf->m_len = new_mbuf->m_pkthdr.len = new_mbuf->m_ext.ext_size;
+
+	if (*mbufp) {
+		bus_dmamap_sync(tag, map, BUS_DMASYNC_POSTREAD);
+		bus_dmamap_unload(tag, map);
+	}
+
+	error = bus_dmamap_load_mbuf_sg(tag, map, new_mbuf, seg, &nsegs,
+	    BUS_DMA_NOWAIT);
+	KASSERT(nsegs == 1, ("Too many segments returned!"));
+	if (nsegs != 1 || error)
+		panic("mge_new_rxbuf(): nsegs(%d), error(%d)", nsegs, error);
+
+	bus_dmamap_sync(tag, map, BUS_DMASYNC_PREREAD);
+
+	(*mbufp) = new_mbuf;
+	(*paddr) = seg->ds_addr;
+	return (0);
+}
+
+static int
+mge_alloc_desc_dma(struct mge_softc *sc, struct mge_desc_wrapper* tab,
+    uint32_t size, bus_dma_tag_t *buffer_tag)
+{
+	struct mge_desc_wrapper *dw;
+	bus_addr_t desc_paddr;
+	int i, error;
+
+	desc_paddr = 0;
+	for (i = size - 1; i >= 0; i--) {
+		dw = &(tab[i]);
+		error = bus_dmamem_alloc(sc->mge_desc_dtag,
+		    (void**)&(dw->mge_desc),
+		    BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_COHERENT,
+		    &(dw->desc_dmap));
+
+		if (error) {
+			if_printf(sc->ifp, "failed to allocate DMA memory\n");
+			dw->mge_desc = NULL;
+			return (ENXIO);
+		}
+
+		error = bus_dmamap_load(sc->mge_desc_dtag, dw->desc_dmap,
+		    dw->mge_desc, sizeof(struct mge_desc), mge_get_dma_addr,
+		    &(dw->mge_desc_paddr), BUS_DMA_NOWAIT);
+
+		if (error) {
+			if_printf(sc->ifp, "can't load descriptor\n");
+			bus_dmamem_free(sc->mge_desc_dtag, dw->mge_desc,
+			    dw->desc_dmap);
+			dw->mge_desc = NULL;
+			return (ENXIO);
+		}
+
+		/* Chain descriptors */
+		dw->mge_desc->next_desc = desc_paddr;
+		desc_paddr = dw->mge_desc_paddr;
+	}
+	tab[size - 1].mge_desc->next_desc = desc_paddr;
+
+	/* Allocate a busdma tag for mbufs. */
+	error = bus_dma_tag_create(NULL,	/* parent */
+	    8, 0,				/* alignment, boundary */
+	    BUS_SPACE_MAXADDR_32BIT,		/* lowaddr */
+	    BUS_SPACE_MAXADDR,			/* highaddr */
+	    NULL, NULL,				/* filtfunc, filtfuncarg */
+	    MCLBYTES, 1,			/* maxsize, nsegments */
+	    MCLBYTES, 0,			/* maxsegsz, flags */
+	    NULL, NULL,				/* lockfunc, lockfuncarg */
+	    buffer_tag);			/* dmat */
+	if (error) {
+		if_printf(sc->ifp, "failed to create busdma tag for mbufs\n");
+		return (ENXIO);
+	}
+
+	/* Create TX busdma maps */
+	for (i = 0; i < size; i++) {
+		dw = &(tab[i]);
+		error = bus_dmamap_create(*buffer_tag, 0, &dw->buffer_dmap);
+		if (error) {
+			if_printf(sc->ifp, "failed to create map for mbuf\n");
+			return (ENXIO);
+		}
+
+		dw->buffer = (struct mbuf*)NULL;
+		dw->mge_desc->buffer = (bus_addr_t)NULL;
+	}
+
+	return (0);
+}
+
+static int
+mge_allocate_dma(struct mge_softc *sc)
+{
+	int error;
+	struct mge_desc_wrapper *dw;
+	int num, i;
+
+
+	num = MGE_TX_DESC_NUM + MGE_RX_DESC_NUM;
+
+	/* Allocate a busdma tag and DMA safe memory for TX/RX descriptors. */
+	error = bus_dma_tag_create(NULL,	/* parent */
+	    16, 0,				/* alignment, boundary */
+	    BUS_SPACE_MAXADDR_32BIT,		/* lowaddr */
+	    BUS_SPACE_MAXADDR,			/* highaddr */
+	    NULL, NULL,				/* filtfunc, filtfuncarg */
+	    sizeof(struct mge_desc), 1,		/* maxsize, nsegments */
+	    sizeof(struct mge_desc), 0,		/* maxsegsz, flags */
+	    NULL, NULL,				/* lockfunc, lockfuncarg */
+	    &sc->mge_desc_dtag);		/* dmat */
+
+
+	mge_alloc_desc_dma(sc, sc->mge_tx_desc, MGE_TX_DESC_NUM,
+	    &sc->mge_tx_dtag);
+	mge_alloc_desc_dma(sc, sc->mge_rx_desc, MGE_RX_DESC_NUM,
+	    &sc->mge_rx_dtag);
+
+	for (i = 0; i < MGE_RX_DESC_NUM; i++) {
+		dw = &(sc->mge_rx_desc[i]);
+		mge_new_rxbuf(sc->mge_rx_dtag, dw->buffer_dmap, &dw->buffer,
+		    &dw->mge_desc->buffer);
+	}
+
+	sc->tx_desc_start = sc->mge_tx_desc[0].mge_desc_paddr;
+	sc->rx_desc_start = sc->mge_rx_desc[0].mge_desc_paddr;
+
+	return (0);
+}
+
+static void
+mge_free_desc(struct mge_softc *sc, struct mge_desc_wrapper* tab,
+    uint32_t size, bus_dma_tag_t buffer_tag, uint8_t free_mbufs)
+{
+	struct mge_desc_wrapper *dw;
+	int i;
+
+	for (i = 0; i < size; i++) {
+		/* Free RX mbuf */
+		dw = &(tab[i]);
+
+		if (dw->buffer_dmap) {
+			if (free_mbufs) {
+				bus_dmamap_sync(buffer_tag, dw->buffer_dmap,
+				    BUS_DMASYNC_POSTREAD);
+				bus_dmamap_unload(buffer_tag, dw->buffer_dmap);
+			}
+			bus_dmamap_destroy(buffer_tag, dw->buffer_dmap);
+			if (free_mbufs)
+				m_freem(dw->buffer);
+		}
+		/* Free RX descriptors */
+		if (dw->desc_dmap) {
+			bus_dmamap_sync(sc->mge_desc_dtag, dw->desc_dmap,
+			    BUS_DMASYNC_POSTREAD);
+			bus_dmamap_unload(sc->mge_desc_dtag, dw->desc_dmap);
+			bus_dmamem_free(sc->mge_desc_dtag, dw->mge_desc,
+			    dw->desc_dmap);
+		}
+	}
+}
+
+static void
+mge_free_dma(struct mge_softc *sc)
+{
+	/* Free desciptors and mbufs */
+	mge_free_desc(sc, sc->mge_rx_desc, MGE_RX_DESC_NUM, sc->mge_rx_dtag, 1);
+	mge_free_desc(sc, sc->mge_tx_desc, MGE_TX_DESC_NUM, sc->mge_tx_dtag, 0);
+
+	/* Destroy mbuf dma tag */
+	bus_dma_tag_destroy(sc->mge_tx_dtag);
+	bus_dma_tag_destroy(sc->mge_rx_dtag);
+	/* Destroy descriptors tag */
+	bus_dma_tag_destroy(sc->mge_desc_dtag);
+}
+
+static void
+mge_reinit_rx(struct mge_softc *sc)
+{
+	struct mge_desc_wrapper *dw;
+	int i;
+
+	MGE_RECEIVE_LOCK(sc);
+
+	mge_free_desc(sc, sc->mge_rx_desc, MGE_RX_DESC_NUM, sc->mge_rx_dtag, 1);
+
+	mge_alloc_desc_dma(sc, sc->mge_rx_desc, MGE_RX_DESC_NUM,
+	    &sc->mge_rx_dtag);
+
+	for (i = 0; i < MGE_RX_DESC_NUM; i++) {
+		dw = &(sc->mge_rx_desc[i]);
+		mge_new_rxbuf(sc->mge_rx_dtag, dw->buffer_dmap, &dw->buffer,
+		&dw->mge_desc->buffer);
+	}
+
+	sc->rx_desc_start = sc->mge_rx_desc[0].mge_desc_paddr;
+	sc->rx_desc_curr = 0;
+
+	MGE_WRITE(sc, MGE_RX_CUR_DESC_PTR(MGE_RX_DEFAULT_QUEUE),
+	    sc->rx_desc_start);
+
+	/* Enable RX queue */
+	MGE_WRITE(sc, MGE_RX_QUEUE_CMD, MGE_ENABLE_RXQ(MGE_RX_DEFAULT_QUEUE));
+
+	MGE_RECEIVE_UNLOCK(sc);
+}
+
+#ifdef DEVICE_POLLING
+static poll_handler_t mge_poll;
+
+static void
+mge_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
+{
+	struct mge_softc *sc = ifp->if_softc;
+	uint32_t int_cause, int_cause_ext;
+
+	MGE_GLOBAL_LOCK(sc);
+
+	if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
+		MGE_GLOBAL_UNLOCK(sc);
+		return;
+	}
+
+	if (cmd == POLL_AND_CHECK_STATUS) {
+		int_cause = MGE_READ(sc, MGE_PORT_INT_CAUSE);
+		int_cause_ext = MGE_READ(sc, MGE_PORT_INT_CAUSE_EXT);
+
+		/* Check for resource error */
+		if (int_cause & MGE_PORT_INT_RXERRQ0)
+			mge_reinit_rx(sc);
+
+		if (int_cause || int_cause_ext) {
+			MGE_WRITE(sc, MGE_PORT_INT_CAUSE, ~int_cause);
+			MGE_WRITE(sc, MGE_PORT_INT_CAUSE_EXT, ~int_cause_ext);
+		}
+	}
+
+	mge_intr_tx_locked(sc);
+	mge_intr_rx_locked(sc, count);
+
+	MGE_GLOBAL_UNLOCK(sc);
+}
+#endif /* DEVICE_POLLING */
+
+static int
+mge_attach(device_t dev)
+{
+	struct mge_softc *sc;
+	struct ifnet *ifp;
+	uint8_t hwaddr[ETHER_ADDR_LEN];
+	int i, error ;
+
+	sc = device_get_softc(dev);
+	sc->dev = dev;
+
+	if (device_get_unit(dev) == 0)
+		sc_mge0 = sc;
+
+	/* Initialize mutexes */
+	mtx_init(&sc->transmit_lock, device_get_nameunit(dev), "mge TX lock", MTX_DEF);
+	mtx_init(&sc->receive_lock, device_get_nameunit(dev), "mge RX lock", MTX_DEF);
+
+	/* Allocate IO and IRQ resources */
+	error = bus_alloc_resources(dev, res_spec, sc->res);
+	if (error) {
+		device_printf(dev, "could not allocate resources\n");
+		mge_detach(dev);
+		return (ENXIO);
+	}
+
+	/* Allocate DMA, buffers, buffer descriptors */
+	error = mge_allocate_dma(sc);
+	if (error) {
+		mge_detach(dev);
+		return (ENXIO);
+	}
+
+	sc->tx_desc_curr = 0;
+	sc->rx_desc_curr = 0;
+	sc->tx_desc_used_idx = 0;
+
+	/* Configure defaults for interrupts coalescing */
+	sc->rx_ic_time = 768;
+	sc->tx_ic_time = 768;
+	mge_add_sysctls(sc);
+
+	/* Allocate network interface */
+	ifp = sc->ifp = if_alloc(IFT_ETHER);
+	if (ifp == NULL) {
+		device_printf(dev, "if_alloc() failed\n");
+		mge_detach(dev);
+		return (ENOMEM);
+	}
+
+	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
+	ifp->if_softc = sc;
+	ifp->if_flags = IFF_SIMPLEX | IFF_MULTICAST | IFF_BROADCAST;
+	ifp->if_capabilities = IFCAP_HWCSUM | IFCAP_VLAN_MTU;
+	ifp->if_capenable = ifp->if_capabilities;
+	ifp->if_hwassist = MGE_CHECKSUM_FEATURES;
+
+#ifdef DEVICE_POLLING
+	/* Advertise that polling is supported */
+	ifp->if_capabilities |= IFCAP_POLLING;
+#endif
+
+	ifp->if_init = mge_init;
+	ifp->if_start = mge_start;
+	ifp->if_ioctl = mge_ioctl;
+
+	ifp->if_snd.ifq_drv_maxlen = MGE_TX_DESC_NUM - 1;
+	IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen);
+	IFQ_SET_READY(&ifp->if_snd);
+
+	mge_get_mac_address(sc, hwaddr);
+	ether_ifattach(ifp, hwaddr);
+	callout_init(&sc->wd_callout, 0);
+
+	/* Probe PHY(s) */
+	error = mii_phy_probe(dev, &sc->miibus, mge_ifmedia_upd, mge_ifmedia_sts);
+	if (error) {
+		device_printf(dev, "MII failed to find PHY\n");
+		if_free(ifp);
+		sc->ifp = NULL;
+		mge_detach(dev);
+		return (error);
+	}
+	sc->mii = device_get_softc(sc->miibus);
+
+	/* Attach interrupt handlers */
+	for (i = 0; i < 2; ++i) {
+		error = bus_setup_intr(dev, sc->res[1 + i],
+		    INTR_TYPE_NET | INTR_MPSAFE, NULL, *mge_intrs[i].handler,
+		    sc, &sc->ih_cookie[i]);
+		if (error) {
+			device_printf(dev, "could not setup %s\n",
+			    mge_intrs[i].description);
+			ether_ifdetach(sc->ifp);
+			return (error);
+		}
+	}
+
+	return (0);
+}
+
+static int
+mge_detach(device_t dev)
+{
+	struct mge_softc *sc;
+	int error,i;
+
+	sc = device_get_softc(dev);
+
+	/* Stop controller and free TX queue */
+	if (sc->ifp)
+		mge_shutdown(dev);
+
+	/* Wait for stopping ticks */
+        callout_drain(&sc->wd_callout);
+
+	/* Stop and release all interrupts */
+	for (i = 0; i < 2; ++i) {
+		error = bus_teardown_intr(dev, sc->res[1 + i], sc->ih_cookie[i]);
+		if (error)
+			device_printf(dev, "could not release %s\n",
+			    mge_intrs[i].description);
+	}
+
+	/* Detach network interface */
+	if (sc->ifp) {
+		ether_ifdetach(sc->ifp);
+		if_free(sc->ifp);
+	}
+
+	/* Free DMA resources */
+	mge_free_dma(sc);
+
+	/* Free IO memory handler */
+	bus_release_resources(dev, res_spec, sc->res);
+
+	/* Destroy mutexes */
+	mtx_destroy(&sc->receive_lock);
+	mtx_destroy(&sc->transmit_lock);
+
+	return (0);
+}
+
+static void
+mge_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
+{
+	struct mge_softc *sc = ifp->if_softc;
+	struct mii_data *mii;
+
+	MGE_TRANSMIT_LOCK(sc);
+
+	mii = sc->mii;
+	mii_pollstat(mii);
+
+	ifmr->ifm_active = mii->mii_media_active;
+	ifmr->ifm_status = mii->mii_media_status;
+
+	MGE_TRANSMIT_UNLOCK(sc);
+}
+
+static uint32_t
+mge_set_port_serial_control(uint32_t media)
+{
+	uint32_t port_config;
+
+	port_config = PORT_SERIAL_RES_BIT9 | PORT_SERIAL_FORCE_LINK_FAIL |
+	    PORT_SERIAL_MRU(PORT_SERIAL_MRU_1552);
+
+	if (IFM_TYPE(media) == IFM_ETHER) {
+		switch(IFM_SUBTYPE(media)) {
+			case IFM_AUTO:
+				break;
+			case IFM_1000_T:
+				port_config  |= (PORT_SERIAL_GMII_SPEED_1000 |
+				    PORT_SERIAL_AUTONEG | PORT_SERIAL_AUTONEG_FC |
+				    PORT_SERIAL_SPEED_AUTONEG);
+				break;
+			case IFM_100_TX:
+				port_config  |= (PORT_SERIAL_MII_SPEED_100 |
+				    PORT_SERIAL_AUTONEG | PORT_SERIAL_AUTONEG_FC |
+				    PORT_SERIAL_SPEED_AUTONEG);
+				break;
+			case IFM_10_T:
+				port_config  |= (PORT_SERIAL_AUTONEG |
+				    PORT_SERIAL_AUTONEG_FC |
+				    PORT_SERIAL_SPEED_AUTONEG);
+				break;
+		}
+		if (media & IFM_FDX)
+			port_config |= PORT_SERIAL_FULL_DUPLEX;
+	}
+	return (port_config);
+}
+
+static int
+mge_ifmedia_upd(struct ifnet *ifp)
+{
+	struct mge_softc *sc = ifp->if_softc;
+
+	if (ifp->if_flags & IFF_UP) {
+		MGE_GLOBAL_LOCK(sc);
+
+		sc->mge_media_status = sc->mii->mii_media.ifm_media;
+		mii_mediachg(sc->mii);
+		mge_init_locked(sc);
+
+		MGE_GLOBAL_UNLOCK(sc);
+	}
+
+	return (0);
+}
+
+static void
+mge_init(void *arg)
+{
+	struct mge_softc *sc = arg;
+
+	MGE_GLOBAL_LOCK(sc);
+
+	mge_init_locked(arg);
+
+	MGE_GLOBAL_UNLOCK(sc);
+}
+
+static void
+mge_init_locked(void *arg)
+{
+	struct mge_softc *sc = arg;
+	struct mge_desc_wrapper *dw;
+	volatile uint32_t reg_val;
+	int i, count;
+
+
+	MGE_GLOBAL_LOCK_ASSERT(sc);
+
+	/* Stop interface */
+	mge_stop(sc);
+
+	/* Disable interrupts */
+	mge_intrs_ctrl(sc, 0);
+
+	/* Set MAC address */
+	mge_set_mac_address(sc);
+
+	/* Setup multicast filters */
+	mge_setup_multicast(sc);
+
+#if defined(MGE_VER2)
+	MGE_WRITE(sc, MGE_PORT_SERIAL_CTRL1, MGE_RGMII_EN);
+	MGE_WRITE(sc, MGE_FIXED_PRIO_CONF, MGE_FIXED_PRIO_EN(0));
+#endif
+	/* Initialize TX queue configuration registers */
+	MGE_WRITE(sc, MGE_TX_TOKEN_COUNT(0), MGE_TX_TOKEN_Q0_DFLT);
+	MGE_WRITE(sc, MGE_TX_TOKEN_CONF(0), MGE_TX_TOKEN_Q0_DFLT);
+	MGE_WRITE(sc, MGE_TX_ARBITER_CONF(0), MGE_TX_ARB_Q0_DFLT);
+
+	for (i = 1; i < 7; i++) {
+		MGE_WRITE(sc, MGE_TX_TOKEN_COUNT(i), MGE_TX_TOKEN_Q1_7_DFLT);
+		MGE_WRITE(sc, MGE_TX_TOKEN_CONF(i), MGE_TX_TOKEN_Q1_7_DFLT);
+		MGE_WRITE(sc, MGE_TX_ARBITER_CONF(i), MGE_TX_ARB_Q1_7_DFLT);
+	}
+
+	/* Set default MTU */
+	MGE_WRITE(sc, MGE_MTU, MGE_MTU_DEFAULT);
+
+	/* Port configuration */
+	MGE_WRITE(sc, MGE_PORT_CONFIG,
+	    PORT_CONFIG_RXCS | PORT_CONFIG_DFLT_RXQ(0) |
+	    PORT_CONFIG_ARO_RXQ(0));
+	MGE_WRITE(sc, MGE_PORT_EXT_CONFIG , 0x0);
+
+	/* Setup port configuration */
+	reg_val = mge_set_port_serial_control(sc->mge_media_status);
+	MGE_WRITE(sc, MGE_PORT_SERIAL_CTRL, reg_val);
+
+	/* Setup SDMA configuration */
+	MGE_WRITE(sc, MGE_SDMA_CONFIG , MGE_SDMA_RX_BYTE_SWAP |
+	    MGE_SDMA_TX_BYTE_SWAP |
+	    MGE_SDMA_RX_BURST_SIZE(MGE_SDMA_BURST_16_WORD) |
+	    MGE_SDMA_TX_BURST_SIZE(MGE_SDMA_BURST_16_WORD));
+
+	MGE_WRITE(sc, MGE_TX_FIFO_URGENT_TRSH, 0x0);
+
+	MGE_WRITE(sc, MGE_TX_CUR_DESC_PTR, sc->tx_desc_start);
+	MGE_WRITE(sc, MGE_RX_CUR_DESC_PTR(MGE_RX_DEFAULT_QUEUE),
+	    sc->rx_desc_start);
+
+	/* Reset descriptor indexes */
+	sc->tx_desc_curr = 0;
+	sc->rx_desc_curr = 0;
+	sc->tx_desc_used_idx = 0;
+
+	/* Enable RX descriptors */
+	for (i = 0; i < MGE_RX_DESC_NUM; i++) {
+		dw = &sc->mge_rx_desc[i];
+		dw->mge_desc->cmd_status = MGE_RX_ENABLE_INT | MGE_DMA_OWNED;
+		dw->mge_desc->buff_size = MCLBYTES;
+		bus_dmamap_sync(sc->mge_desc_dtag, dw->desc_dmap,
+		    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+	}
+
+	/* Enable RX queue */
+	MGE_WRITE(sc, MGE_RX_QUEUE_CMD, MGE_ENABLE_RXQ(MGE_RX_DEFAULT_QUEUE));
+
+	/* Enable port */
+	reg_val = MGE_READ(sc, MGE_PORT_SERIAL_CTRL);
+	reg_val |= PORT_SERIAL_ENABLE;
+	MGE_WRITE(sc, MGE_PORT_SERIAL_CTRL, reg_val);
+	count = 0x100000;
+	for (;;) {
+		reg_val = MGE_READ(sc, MGE_PORT_STATUS);
+		if (reg_val & MGE_STATUS_LINKUP)
+			break;
+		DELAY(100);
+		if (--count == 0) {
+			if_printf(sc->ifp, "Timeout on link-up\n");
+			break;
+		}
+	}
+
+	/* Setup interrupts coalescing */
+	mge_set_rxic(sc);
+	mge_set_txic(sc);
+
+	/* Enable interrupts */
+#ifdef DEVICE_POLLING
+        /*
+	 * * ...only if polling is not turned on. Disable interrupts explicitly
+	 * if polling is enabled.
+	 */
+	if (sc->ifp->if_capenable & IFCAP_POLLING)
+		mge_intrs_ctrl(sc, 0);
+	else
+#endif /* DEVICE_POLLING */
+	mge_intrs_ctrl(sc, 1);
+
+	/* Activate network interface */
+	sc->ifp->if_drv_flags |= IFF_DRV_RUNNING;
+	sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+	sc->wd_timer = 0;
+
+	/* Schedule watchdog timeout */
+	callout_reset(&sc->wd_callout, hz, mge_tick, sc);
+}
+
+static void
+mge_intr_err(void *arg)
+{
+	struct mge_softc *sc = arg;
+	struct ifnet *ifp;
+
+	ifp = sc->ifp;
+	if_printf(ifp, "%s\n", __FUNCTION__);
+}
+
+static void
+mge_intr_misc(void *arg)
+{
+	struct mge_softc *sc = arg;
+	struct ifnet *ifp;
+
+	ifp = sc->ifp;
+	if_printf(ifp, "%s\n", __FUNCTION__);
+}
+
+static void
+mge_intr_rx(void *arg) {
+	struct mge_softc *sc = arg;
+	uint32_t int_cause, int_cause_ext;
+
+	MGE_RECEIVE_LOCK(sc);
+
+#ifdef DEVICE_POLLING
+	if (sc->ifp->if_capenable & IFCAP_POLLING) {
+		MGE_RECEIVE_UNLOCK(sc);
+		return;
+	}
+#endif
+
+	/* Get interrupt cause */
+	int_cause = MGE_READ(sc, MGE_PORT_INT_CAUSE);
+	int_cause_ext = MGE_READ(sc, MGE_PORT_INT_CAUSE_EXT);
+
+	/* Check for resource error */
+	if (int_cause & MGE_PORT_INT_RXERRQ0) {
+		mge_reinit_rx(sc);
+		MGE_WRITE(sc, MGE_PORT_INT_CAUSE,
+		    int_cause & ~MGE_PORT_INT_RXERRQ0);
+	}
+
+	int_cause &= MGE_PORT_INT_RXQ0;
+	int_cause_ext &= MGE_PORT_INT_EXT_RXOR;
+
+	if (int_cause || int_cause_ext) {
+		MGE_WRITE(sc, MGE_PORT_INT_CAUSE, ~int_cause);
+		MGE_WRITE(sc, MGE_PORT_INT_CAUSE_EXT, ~int_cause_ext);
+		mge_intr_rx_locked(sc, -1);
+	}
+
+	MGE_RECEIVE_UNLOCK(sc);
+}
+
+
+static void
+mge_intr_rx_locked(struct mge_softc *sc, int count)
+{
+	struct ifnet *ifp = sc->ifp;
+	uint32_t status;
+	uint16_t bufsize;
+	struct mge_desc_wrapper* dw;
+	struct mbuf *mb;
+
+	MGE_RECEIVE_LOCK_ASSERT(sc);
+
+	while(count != 0) {
+		dw = &sc->mge_rx_desc[sc->rx_desc_curr];
+		bus_dmamap_sync(sc->mge_desc_dtag, dw->desc_dmap,
+		    BUS_DMASYNC_POSTREAD);
+
+		/* Get status */
+		status = dw->mge_desc->cmd_status;
+		bufsize = dw->mge_desc->buff_size;
+		if ((status & MGE_DMA_OWNED) != 0)
+			break;
+
+		sc->rx_desc_curr = (++sc->rx_desc_curr % MGE_RX_DESC_NUM);
+		if (dw->mge_desc->byte_count &&
+		    ~(status & MGE_ERR_SUMMARY)) {
+
+			bus_dmamap_sync(sc->mge_rx_dtag, dw->buffer_dmap,
+			    BUS_DMASYNC_POSTREAD);
+
+			mb = m_devget(dw->buffer->m_data,
+			    dw->mge_desc->byte_count - ETHER_CRC_LEN,
+			    0, ifp, NULL);
+
+			mb->m_len -= 2;
+			mb->m_pkthdr.len -= 2;
+			mb->m_data += 2;
+
+			mge_offload_process_frame(ifp, mb, status,
+			    bufsize);
+
+			MGE_RECEIVE_UNLOCK(sc);
+			(*ifp->if_input)(ifp, mb);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
From n_hibma at FreeBSD.org  Tue Oct 14 07:45:11 2008
From: n_hibma at FreeBSD.org (Nick Hibma)
Date: Tue Oct 14 07:45:17 2008
Subject: svn commit: r183868 - head/sys/dev/usb
Message-ID: <200810140745.m9E7jBai099067@svn.freebsd.org>

Author: n_hibma
Date: Tue Oct 14 07:45:11 2008
New Revision: 183868
URL: http://svn.freebsd.org/changeset/base/183868

Log:
  - Fix the naming of the MC950D device.
  - Remove the (unimplemented) U3GFL_EJECT quirk as this won't be implemented in
    the u3g driver anyway (most probably as an entry in devd.conf)

Modified:
  head/sys/dev/usb/u3g.c
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/u3g.c
==============================================================================
--- head/sys/dev/usb/u3g.c	Tue Oct 14 07:24:18 2008	(r183867)
+++ head/sys/dev/usb/u3g.c	Tue Oct 14 07:45:11 2008	(r183868)
@@ -90,7 +90,6 @@ struct u3g_dev_type_s {
 	u_int16_t		u3g_flags;
 #define U3GFL_NONE		0x0000
 #define U3GFL_HUAWEI_INIT	0x0001		/* Send USB command to reset iface to ucom mode */
-#define U3GFL_EJECT		0x0002		/* Send SCSI eject to reset first iface to ucom mode */
 };
 
 static const struct u3g_dev_type_s u3g_devs[] = {
@@ -108,17 +107,17 @@ static const struct u3g_dev_type_s u3g_d
 	/* OEM: Novatel */
 	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_CDMA_MODEM },	U3GFL_NONE },
 	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_ES620 },		U3GFL_NONE },
+	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_MC950D },		U3GFL_NONE },
 	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U720 },		U3GFL_NONE },
 	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U727 },		U3GFL_NONE },
 	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740 },		U3GFL_NONE },
 	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740_2 },		U3GFL_NONE },
-	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U950D },		U3GFL_EJECT },
+	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U870 },		U3GFL_NONE },
 	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V620 },		U3GFL_NONE },
 	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V640 },		U3GFL_NONE },
 	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V720 },		U3GFL_NONE },
 	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V740 },		U3GFL_NONE },
 	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_X950D },		U3GFL_NONE },
-	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U870 },		U3GFL_NONE },
 	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_XU870 },		U3GFL_NONE },
 	{{ USB_VENDOR_DELL,    USB_PRODUCT_DELL_U740 },			U3GFL_NONE },
 };

Modified: head/sys/dev/usb/usbdevs
==============================================================================
--- head/sys/dev/usb/usbdevs	Tue Oct 14 07:24:18 2008	(r183867)
+++ head/sys/dev/usb/usbdevs	Tue Oct 14 07:45:11 2008	(r183868)
@@ -1839,7 +1839,7 @@ product NOVATEL X950D		0x1450	Merlin X95
 product NOVATEL ES620		0x2100	ES620 CDMA
 product NOVATEL U720		0x2110	Merlin U720
 product NOVATEL U727		0x4100	Merlin U727 CDMA
-product NOVATEL U950D		0x4400	Novatel MC950D HSUPA
+product NOVATEL MC950D		0x4400	Novatel MC950D HSUPA
 product NOVATEL ZEROCD		0x5010	Novatel ZeroCD
 product NOVATEL2 FLEXPACKGPS	0x0100	NovAtel FlexPack GPS receiver
 
From n_hibma at FreeBSD.org  Tue Oct 14 07:52:48 2008
From: n_hibma at FreeBSD.org (Nick Hibma)
Date: Tue Oct 14 07:52:54 2008
Subject: svn commit: r183869 - head/sys/dev/usb
Message-ID: <200810140752.m9E7qlVn099218@svn.freebsd.org>

Author: n_hibma
Date: Tue Oct 14 07:52:47 2008
New Revision: 183869
URL: http://svn.freebsd.org/changeset/base/183869

Log:
  Fix a comment.
  
  Submitted by:	Nick Mann

Modified:
  head/sys/dev/usb/umass.c

Modified: head/sys/dev/usb/umass.c
==============================================================================
--- head/sys/dev/usb/umass.c	Tue Oct 14 07:45:11 2008	(r183868)
+++ head/sys/dev/usb/umass.c	Tue Oct 14 07:52:47 2008	(r183869)
@@ -1177,17 +1177,16 @@ umass_match_proto(struct umass_softc *sc
 
 	dd = usbd_get_device_descriptor(udev);
 
-	/* These are 3G modes (E220, Mobile, etc.) devices with auto-install
-	 * flash disks for Windows/MacOSX through the first interface.
-	 * We are assuming that these vendors will not produce mass storage
-	 * devices. See the list of supported parts in u3g, if this happens to
-	 * be a mistake in the future.
+	/* These are 3G modem devices (E220, Mobile, etc.) with auto-install
+	 * flash disks for Windows/MacOSX through the first interface. We are
+	 * assuming that these vendors will not produce mass storage devices.
+	 * See the list of supported parts in u3g, if this happens to be a
+	 * mistake in the future.
 	 */
 	if (UGETW(dd->idVendor) == USB_VENDOR_HUAWEI) {
-		/* The interface is reset in the u3g driver
-		 * (u3g_huawei_reinit()). Allow generic attachment to the
-		 * second interface though. Some Huawei devices contain an SD
-		 * card slot.
+		/* The interface is reset in the u3g driver. Allow generic
+		 * attachment to the second interface though. Some Huawei
+		 * devices contain an SD card slot.
 		 */
 		id = usbd_get_interface_descriptor(iface);
 		if (id == NULL || id->bInterfaceNumber == 0)
From kib at FreeBSD.org  Tue Oct 14 07:59:23 2008
From: kib at FreeBSD.org (Konstantin Belousov)
Date: Tue Oct 14 07:59:35 2008
Subject: svn commit: r183871 - in head/sys: amd64/linux32 compat/linux
	i386/linux
Message-ID: <200810140759.m9E7xNwX099428@svn.freebsd.org>

Author: kib
Date: Tue Oct 14 07:59:23 2008
New Revision: 183871
URL: http://svn.freebsd.org/changeset/base/183871

Log:
  Make robust futexes work on linux32/amd64. Use PTRIN to read
  user-mode pointers. Change types used in the structures definitions to
  properly-sized architecture-specific types.
  
  Submitted by:	dchagin
  MFC after:	1 week

Modified:
  head/sys/amd64/linux32/linux.h
  head/sys/compat/linux/linux_futex.c
  head/sys/compat/linux/linux_futex.h
  head/sys/i386/linux/linux.h

Modified: head/sys/amd64/linux32/linux.h
==============================================================================
--- head/sys/amd64/linux32/linux.h	Tue Oct 14 07:58:18 2008	(r183870)
+++ head/sys/amd64/linux32/linux.h	Tue Oct 14 07:59:23 2008	(r183871)
@@ -880,4 +880,15 @@ typedef int l_mqd_t;
 	(LINUX_CLONE_VM | LINUX_CLONE_FS | LINUX_CLONE_FILES |	\
 	LINUX_CLONE_SIGHAND | LINUX_CLONE_THREAD)
 
+/* robust futexes */
+struct linux_robust_list {
+	l_uintptr_t			next;
+};
+
+struct linux_robust_list_head {
+	struct linux_robust_list	list;
+	l_ulong				futex_offset;
+	l_uintptr_t			pending_list;
+};
+
 #endif /* !_AMD64_LINUX_H_ */

Modified: head/sys/compat/linux/linux_futex.c
==============================================================================
--- head/sys/compat/linux/linux_futex.c	Tue Oct 14 07:58:18 2008	(r183870)
+++ head/sys/compat/linux/linux_futex.c	Tue Oct 14 07:59:23 2008	(r183871)
@@ -661,17 +661,17 @@ release_futexes(struct proc *p)
 	if (head == NULL)
 		return;
 
-	if (fetch_robust_entry(&entry, &head->list.next, &pi))
+	if (fetch_robust_entry(&entry, PTRIN(&head->list.next), &pi))
 		return;
 
 	if (copyin(&head->futex_offset, &futex_offset, sizeof(l_ulong)))
 		return;
 
-	if (fetch_robust_entry(&pending, &head->pending_list, &pip))
+	if (fetch_robust_entry(&pending, PTRIN(&head->pending_list), &pip))
 		return;
 
 	while (entry != &head->list) {
-		rc = fetch_robust_entry(&next_entry, &entry->next, &next_pi);
+		rc = fetch_robust_entry(&next_entry, PTRIN(&entry->next), &next_pi);
 
 		if (entry != pending)
 			if (handle_futex_death((char *)entry + futex_offset,

Modified: head/sys/compat/linux/linux_futex.h
==============================================================================
--- head/sys/compat/linux/linux_futex.h	Tue Oct 14 07:58:18 2008	(r183870)
+++ head/sys/compat/linux/linux_futex.h	Tue Oct 14 07:59:23 2008	(r183871)
@@ -63,18 +63,6 @@
 #define FUTEX_OP_CMP_GT         4	/* if (oldval > CMPARG) wake */
 #define FUTEX_OP_CMP_GE         5	/* if (oldval >= CMPARG) wake */
 
-/* This is defined by Linux user-space */
-
-struct linux_robust_list {
-	struct linux_robust_list	*next;
-};
-
-struct linux_robust_list_head {
-	struct linux_robust_list	list;
-	l_ulong				futex_offset;
-	struct linux_robust_list	*pending_list;
-};
-
 #define	FUTEX_WAITERS		0x80000000
 #define	FUTEX_OWNER_DIED	0x40000000
 #define	FUTEX_TID_MASK		0x3fffffff

Modified: head/sys/i386/linux/linux.h
==============================================================================
--- head/sys/i386/linux/linux.h	Tue Oct 14 07:58:18 2008	(r183870)
+++ head/sys/i386/linux/linux.h	Tue Oct 14 07:59:23 2008	(r183871)
@@ -845,4 +845,15 @@ typedef int l_mqd_t;
 	(LINUX_CLONE_VM | LINUX_CLONE_FS | LINUX_CLONE_FILES |	\
 	LINUX_CLONE_SIGHAND | LINUX_CLONE_THREAD)
 
+/* robust futexes */
+struct linux_robust_list {
+	struct linux_robust_list	*next;
+};
+
+struct linux_robust_list_head {
+	struct linux_robust_list	list;
+	l_ulong				futex_offset;
+	struct linux_robust_list	*pending_list;
+};
+
 #endif /* !_I386_LINUX_H_ */
From raj at FreeBSD.org  Tue Oct 14 08:18:27 2008
From: raj at FreeBSD.org (Rafal Jaworowski)
Date: Tue Oct 14 08:18:33 2008
Subject: svn commit: r183873 - head/sys/arm/conf
Message-ID: <200810140818.m9E8IRLX099905@svn.freebsd.org>

Author: raj
Date: Tue Oct 14 08:18:27 2008
New Revision: 183873
URL: http://svn.freebsd.org/changeset/base/183873

Log:
  Add kernel config files for Marvell development boards.
  
  FreeBSD 8-CURRENT was tested and run successfully on the following eval
  boards and devices :
  
    * DB-88F5182, DB-88F5281 (Orion based)
  
    * DB-88F6281, RD-88F6281 (Kirkwood based)
  
    * DB-78100 (Discovery based)
  
  For more detailed info on build instructions and other examples please refer
  to http://wiki.freebsd.org/FreeBSDMarvell
  
  Obtained from:	Marvell, Semihalf

Added:
  head/sys/arm/conf/DB-78XXX   (contents, props changed)
  head/sys/arm/conf/DB-88F5XXX   (contents, props changed)
  head/sys/arm/conf/DB-88F6XXX   (contents, props changed)

Added: head/sys/arm/conf/DB-78XXX
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm/conf/DB-78XXX	Tue Oct 14 08:18:27 2008	(r183873)
@@ -0,0 +1,78 @@
+#
+# Custom kernel for Marvell DB-78xx boards.
+#
+# $FreeBSD$
+#
+
+machine		arm
+ident		DB-88F78XX
+include		"../mv/discovery/std.db78xxx"
+
+options		SOC_MV_DISCOVERY
+
+#makeoptions	DEBUG=-g		#Build kernel with gdb(1) debug symbols
+makeoptions	WERROR="-Werror"
+
+options 	SCHED_4BSD		#4BSD scheduler
+options 	INET			#InterNETworking
+options 	INET6			#IPv6 communications protocols
+options 	FFS			#Berkeley Fast Filesystem
+options 	NFSCLIENT		#Network Filesystem Client
+options		NFSLOCKD		#Network Lock Manager
+options 	NFS_ROOT		#NFS usable as /, requires NFSCLIENT
+options		BOOTP
+options		BOOTP_NFSROOT
+options		BOOTP_NFSV3
+options		BOOTP_WIRED_TO=mge0
+
+#options		ROOTDEVNAME=\"ufs:/dev/da0a\"
+
+options 	SYSVSHM			#SYSV-style shared memory
+options 	SYSVMSG			#SYSV-style message queues
+options 	SYSVSEM			#SYSV-style semaphores
+options 	_KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
+options 	MUTEX_NOINLINE
+options		RWLOCK_NOINLINE
+options 	NO_FFS_SNAPSHOT
+options 	NO_SWAPPING
+
+# Debugging
+options		ALT_BREAK_TO_DEBUGGER
+options		DDB
+options		DIAGNOSTIC
+#options 	INVARIANTS		#Enable calls of extra sanity checking
+#options 	INVARIANT_SUPPORT	#Extra sanity checks of internal structures, required by INVARIANTS
+options		KDB
+options 	WITNESS			#Enable checks to detect deadlocks and cycles
+options 	WITNESS_SKIPSPIN	#Don't run witness on spinlocks for speed
+#options		WITNESS_KDB
+
+# Pseudo devices
+device		loop
+device		mem
+device		md
+device		pty
+device		random
+
+# Serial ports
+device		uart
+
+# Networking
+device		ether
+device		mge			# Marvell Gigabit Ethernet controller
+device		mii
+device		e1000phy
+device		bpf
+
+# USB
+device		usb
+device		ehci
+device		umass
+device		scbus
+device		pass
+device		da
+
+# I2C (TWSI)
+device		iic
+device		iicbus
+device		ds133x

Added: head/sys/arm/conf/DB-88F5XXX
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm/conf/DB-88F5XXX	Tue Oct 14 08:18:27 2008	(r183873)
@@ -0,0 +1,80 @@
+#
+# Custom kernel for Marvell DB-88F5xxx boards.
+#
+# $FreeBSD$
+#
+
+machine		arm
+ident		DB-88F5XXX
+include		"../mv/orion/std.db88f5xxx"
+
+options		SOC_MV_ORION
+
+#makeoptions	DEBUG=-g		#Build kernel with gdb(1) debug symbols
+makeoptions	WERROR="-Werror"
+
+options 	SCHED_4BSD		#4BSD scheduler
+options 	INET			#InterNETworking
+options 	INET6			#IPv6 communications protocols
+options 	FFS			#Berkeley Fast Filesystem
+options 	NFSCLIENT		#Network Filesystem Client
+options		NFSLOCKD		#Network Lock Manager
+options 	NFS_ROOT		#NFS usable as /, requires NFSCLIENT
+options		BOOTP
+options		BOOTP_NFSROOT
+options		BOOTP_NFSV3
+options		BOOTP_WIRED_TO=mge0
+
+#options		ROOTDEVNAME=\"ufs:/dev/da0a\"
+
+options 	SYSVSHM			#SYSV-style shared memory
+options 	SYSVMSG			#SYSV-style message queues
+options 	SYSVSEM			#SYSV-style semaphores
+options 	_KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
+options 	MUTEX_NOINLINE
+options		RWLOCK_NOINLINE
+options 	NO_FFS_SNAPSHOT
+options 	NO_SWAPPING
+
+# Debugging
+options		ALT_BREAK_TO_DEBUGGER
+options		DDB
+options		DIAGNOSTIC
+#options 	INVARIANTS		#Enable calls of extra sanity checking
+#options 	INVARIANT_SUPPORT	#Extra sanity checks of internal structures, required by INVARIANTS
+options		KDB
+options 	WITNESS			#Enable checks to detect deadlocks and cycles
+options 	WITNESS_SKIPSPIN	#Don't run witness on spinlocks for speed
+#options		WITNESS_KDB
+
+# Pseudo devices
+device		mem
+device		md
+device		loop
+device		pty
+device		random
+
+# Serial ports
+device		uart
+
+# Networking
+device		ether
+device		mge			# Marvell Gigabit Ethernet controller
+device		mii
+device		e1000phy
+device		bpf
+options		DEVICE_POLLING
+options		HZ=1000
+
+# I2C (TWSI)
+device		iic
+device		iicbus
+device		ds133x
+
+# USB
+device		usb
+device		ehci
+device		umass
+device		scbus
+device		pass
+device		da

Added: head/sys/arm/conf/DB-88F6XXX
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm/conf/DB-88F6XXX	Tue Oct 14 08:18:27 2008	(r183873)
@@ -0,0 +1,77 @@
+#
+# Custom kernel for Marvell DB-88F6xxx boards.
+#
+# $FreeBSD$
+#
+
+machine		arm
+ident		DB-88F6XXX
+include		"../mv/kirkwood/std.db88f6xxx"
+
+options		SOC_MV_KIRKWOOD
+
+#makeoptions	DEBUG=-g		#Build kernel with gdb(1) debug symbols
+makeoptions	WERROR="-Werror"
+
+options 	SCHED_4BSD		#4BSD scheduler
+options 	INET			#InterNETworking
+options 	INET6			#IPv6 communications protocols
+options 	FFS			#Berkeley Fast Filesystem
+options 	NFSCLIENT		#Network Filesystem Client
+options		NFSLOCKD		#Network Lock Manager
+options 	NFS_ROOT		#NFS usable as /, requires NFSCLIENT
+options		BOOTP
+options		BOOTP_NFSROOT
+options		BOOTP_NFSV3
+options		BOOTP_WIRED_TO=mge0
+
+#options		ROOTDEVNAME=\"ufs:/dev/da0a\"
+
+options 	SYSVSHM			#SYSV-style shared memory
+options 	SYSVMSG			#SYSV-style message queues
+options 	SYSVSEM			#SYSV-style semaphores
+options 	_KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
+options 	MUTEX_NOINLINE
+options		RWLOCK_NOINLINE
+options 	NO_FFS_SNAPSHOT
+options 	NO_SWAPPING
+
+# Debugging
+options		ALT_BREAK_TO_DEBUGGER
+options		DDB
+options		DIAGNOSTIC
+#options 	INVARIANTS		#Enable calls of extra sanity checking
+#options 	INVARIANT_SUPPORT	#Extra sanity checks of internal structures, required by INVARIANTS
+options		KDB
+options 	WITNESS			#Enable checks to detect deadlocks and cycles
+options 	WITNESS_SKIPSPIN	#Don't run witness on spinlocks for speed
+#options		WITNESS_KDB
+
+# Pseudo devices
+device		loop
+device		mem
+device		md
+device		pty
+device		random
+
+# Serial ports
+device		uart
+
+# Networking
+device		ether
+device		mge			# Marvell Gigabit Ethernet controller
+device		mii
+device		e1000phy
+device		bpf
+
+# USB
+device		usb
+device		ehci
+device		umass
+device		scbus
+device		pass
+device		da
+
+# I2C (TWSI)
+device		iic
+device		iicbus
From n_hibma at FreeBSD.org  Tue Oct 14 08:41:55 2008
From: n_hibma at FreeBSD.org (Nick Hibma)
Date: Tue Oct 14 08:42:08 2008
Subject: svn commit: r183874 - head/sys/dev/usb
Message-ID: <200810140841.m9E8ft6L000461@svn.freebsd.org>

Author: n_hibma
Date: Tue Oct 14 08:41:54 2008
New Revision: 183874
URL: http://svn.freebsd.org/changeset/base/183874

Log:
  Move all the hacks for the Huawei, Novatel and Qualcomm cards into a stub
  driver.
  
  This stub also hides the devices until they are ready to be used to avoid
  confusion (commented out for now).

Modified:
  head/sys/dev/usb/u3g.c
  head/sys/dev/usb/umass.c

Modified: head/sys/dev/usb/u3g.c
==============================================================================
--- head/sys/dev/usb/u3g.c	Tue Oct 14 08:18:27 2008	(r183873)
+++ head/sys/dev/usb/u3g.c	Tue Oct 14 08:41:54 2008	(r183874)
@@ -94,16 +94,18 @@ struct u3g_dev_type_s {
 
 static const struct u3g_dev_type_s u3g_devs[] = {
 	/* OEM: Option */
-	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3G },		U3GFL_NONE},
-	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GQUAD },		U3GFL_NONE},
-	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GPLUS },		U3GFL_NONE},
-	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GTMAX36 },		U3GFL_NONE},
-	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_VODAFONEMC3G },	U3GFL_NONE},
+	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3G },		U3GFL_NONE },
+	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GQUAD },		U3GFL_NONE },
+	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GPLUS },		U3GFL_NONE },
+	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GTMAX36 },		U3GFL_NONE },
+	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_VODAFONEMC3G },	U3GFL_NONE },
 	/* OEM: Qualcomm, Inc. */
-	{{ USB_VENDOR_QUALCOMMINC, USB_PRODUCT_QUALCOMMINC_CDMA_MSM },	U3GFL_EJECT},
+	{{ USB_VENDOR_QUALCOMMINC, USB_PRODUCT_QUALCOMMINC_CDMA_MSM },	U3GFL_NONE },
 	/* OEM: Huawei */
-	{{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_MOBILE },		U3GFL_HUAWEI_INIT},
-	{{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220 },		U3GFL_HUAWEI_INIT},
+	/* Handled separately. Do not add!
+	{{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_MOBILE },		U3GFL_NONE },
+	{{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220 },		U3GFL_NONE },
+	 */
 	/* OEM: Novatel */
 	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_CDMA_MODEM },	U3GFL_NONE },
 	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_ES620 },		U3GFL_NONE },
@@ -133,51 +135,31 @@ u3g_intr(usbd_xfer_handle xfer, usbd_pri
 #endif
 
 static int
-u3g_huawei_reinit(usbd_device_handle dev, usbd_interface_handle iface)
-{
-	/* The Huawei device presents itself as a umass device with Windows
-	 * drivers on it. After installation of the driver, it reinits into a
-	 * 3G serial device.
-	 */
-	usb_device_request_t req;
-	usb_interface_descriptor_t *idesc;
-
-	if (iface == NULL)
-		return UMATCH_NONE;
-	idesc = usbd_get_interface_descriptor(iface);
-	if (idesc == NULL)
-		return UMATCH_NONE;
-
-	/* If the interface class is no longer mass storage it has changed
-	 * appearance and we should attach it.
-	 */
-	if (idesc->bInterfaceClass == UICLASS_VENDOR)
-		return (UMATCH_VENDOR_PRODUCT_CONF_IFACE);
-
-	req.bmRequestType = UT_WRITE_DEVICE;
-	req.bRequest = UR_SET_FEATURE;
-	USETW(req.wValue, UF_DEVICE_REMOTE_WAKEUP);
-	USETW(req.wIndex, UHF_PORT_SUSPEND);
-	USETW(req.wLength, 0);
-
-	(void) usbd_do_request(dev, &req, 0);
-
-	return UMATCH_NONE;	/* mismatch; it will be gone and reappear */
-}
-
-static int
 u3g_match(device_t self)
 {
 	struct usb_attach_arg *uaa = device_get_ivars(self);
+	usb_interface_descriptor_t *id;
+	const struct u3g_dev_type_s *u3g_dev_type;
 
-	const struct u3g_dev_type_s *u3g_dev_type = u3g_lookup(uaa->vendor, uaa->product);
-	if (u3g_dev_type) {
-		if (u3g_dev_type->u3g_flags & U3GFL_HUAWEI_INIT)
-			return u3g_huawei_reinit(uaa->device, uaa->iface);
-		else
-			return UMATCH_VENDOR_PRODUCT;
+	if (uaa->vendor == USB_VENDOR_HUAWEI) {
+		if (uaa->iface) {
+			/* We attach to the interface instead of the device as
+			 * some devices have a built-in SD card reader on the
+			 * second interface. If the interface class of the
+			 * first interface is no longer mass storage it has
+			 * changed appearance and we should attach it.
+			 */
+			id = usbd_get_interface_descriptor(uaa->iface);
+			if (id && id->bInterfaceClass == UICLASS_VENDOR)
+				return (UMATCH_VENDOR_PRODUCT_CONF_IFACE);
+		}
+		return UMATCH_NONE;
 	}
 
+	u3g_dev_type = u3g_lookup(uaa->vendor, uaa->product);
+	if (u3g_dev_type)
+		return UMATCH_VENDOR_PRODUCT;
+
 	return UMATCH_NONE;
 }
 
@@ -192,7 +174,7 @@ u3g_attach(device_t self)
 	usb_endpoint_descriptor_t *ed;
 	usbd_status error;
 	int i, n; 
-	usb_config_descriptor_t *cdesc;
+	usb_config_descriptor_t *cd;
 	struct ucom_softc *ucom = NULL;
 	char devnamefmt[32];
 
@@ -210,15 +192,15 @@ u3g_attach(device_t self)
 	}
 
 	/* get the config descriptor */
-	cdesc = usbd_get_config_descriptor(dev);
+	cd = usbd_get_config_descriptor(dev);
 
-	if (cdesc == NULL) {
+	if (cd == NULL) {
 		device_printf(self, "failed to get configuration descriptor\n");
 		goto bad;
 	}
 
 	sc->sc_udev = dev;
-	sc->numports = (cdesc->bNumInterface <= U3G_MAXPORTS)?cdesc->bNumInterface:U3G_MAXPORTS;
+	sc->numports = (cd->bNumInterface <= U3G_MAXPORTS)?cd->bNumInterface:U3G_MAXPORTS;
 	for ( i = 0; i < sc->numports; i++ ) {
 		ucom = &sc->sc_ucom[i];
 
@@ -360,3 +342,91 @@ static driver_t u3g_driver = {
 DRIVER_MODULE(u3g, uhub, u3g_driver, ucom_devclass, usbd_driver_load, 0);
 MODULE_DEPEND(u3g, usb, 1, 1, 1);
 MODULE_DEPEND(u3g, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER);
+
+/*******************************************************************
+ ****** Stub driver to hide devices that need to reinitialise ******
+ *******************************************************************/
+
+static void
+u3gstub_huawei_init(usbd_device_handle dev)
+{
+	usb_device_request_t req;
+
+	req.bmRequestType = UT_WRITE_DEVICE;
+	req.bRequest = UR_SET_FEATURE;
+	USETW(req.wValue, UF_DEVICE_REMOTE_WAKEUP);
+	USETW(req.wIndex, UHF_PORT_SUSPEND);
+	USETW(req.wLength, 0);
+
+	(void) usbd_do_request(dev, &req, 0);		/* ignore any error */
+}
+
+static int
+u3gstub_match(device_t self)
+{
+	struct usb_attach_arg *uaa = device_get_ivars(self);
+	usb_device_descriptor_t *dd = usbd_get_device_descriptor(uaa->device);
+	usb_interface_descriptor_t *id;
+
+	/* These are 3G modem devices (E220, Mobile, etc.) with auto-install
+	 * flash disks for Windows/MacOSX through the first interface.
+	 */
+	if (uaa->vendor == USB_VENDOR_HUAWEI) {
+		/* The Huawei device presents itself as a umass device with
+		 * Windows drivers on it. After installation of the driver, it
+		 * reinits into a 3G serial device.
+		 */
+		if (uaa->iface) {
+			id = usbd_get_interface_descriptor(uaa->iface);
+			if (id && id->bInterfaceNumber == 0 && id->bInterfaceClass == UICLASS_MASS) {
+				u3gstub_huawei_init(uaa->device);
+				return (UMATCH_VENDOR_PRODUCT_CONF_IFACE);
+			}
+		}
+	}
+
+	if (UGETW(dd->idVendor) == USB_VENDOR_QUALCOMMINC
+	    || UGETW(dd->idVendor) == USB_VENDOR_NOVATEL) {
+		/* Device by these vendors will automatically reappear as a
+		 * ucom device if ignored (or if sent an eject command).
+		 */
+		return UMATCH_VENDOR_PRODUCT;
+	}
+
+	return UMATCH_NONE;
+}
+
+static int
+u3gstub_attach(device_t self)
+{
+#if 0
+	if (!bootverbose)
+		device_quiet(self);
+#endif
+
+	return 0;
+}
+
+static int
+u3gstub_detach(device_t self)
+{
+	return 0;
+}
+
+static device_method_t u3gstub_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_probe, u3gstub_match),
+	DEVMETHOD(device_attach, u3gstub_attach),
+	DEVMETHOD(device_detach, u3gstub_detach),
+
+	{ 0, 0 }
+};
+
+static driver_t u3gstub_driver = {
+	"u3gstub",
+	u3gstub_methods,
+	0
+};
+
+DRIVER_MODULE(u3gstub, uhub, u3gstub_driver, ucom_devclass, usbd_driver_load, 0);
+MODULE_DEPEND(u3gstub, usb, 1, 1, 1);

Modified: head/sys/dev/usb/umass.c
==============================================================================
--- head/sys/dev/usb/umass.c	Tue Oct 14 08:18:27 2008	(r183873)
+++ head/sys/dev/usb/umass.c	Tue Oct 14 08:41:54 2008	(r183874)
@@ -1177,28 +1177,6 @@ umass_match_proto(struct umass_softc *sc
 
 	dd = usbd_get_device_descriptor(udev);
 
-	/* These are 3G modem devices (E220, Mobile, etc.) with auto-install
-	 * flash disks for Windows/MacOSX through the first interface. We are
-	 * assuming that these vendors will not produce mass storage devices.
-	 * See the list of supported parts in u3g, if this happens to be a
-	 * mistake in the future.
-	 */
-	if (UGETW(dd->idVendor) == USB_VENDOR_HUAWEI) {
-		/* The interface is reset in the u3g driver. Allow generic
-		 * attachment to the second interface though. Some Huawei
-		 * devices contain an SD card slot.
-		 */
-		id = usbd_get_interface_descriptor(iface);
-		if (id == NULL || id->bInterfaceNumber == 0)
-			return UMATCH_NONE;
-	} else if (UGETW(dd->idVendor) == USB_VENDOR_QUALCOMMINC
-		   || UGETW(dd->idVendor) == USB_VENDOR_NOVATEL) {
-		/* Device by these vendors will automatically reappear as a
-		 * ucom device if ignored (or if sent an eject command).
-		 */
-		return UMATCH_NONE;
-	}
-
 	/* An entry specifically for Y-E Data devices as they don't fit in the
 	 * device description table.
 	 */
From raj at FreeBSD.org  Tue Oct 14 09:53:48 2008
From: raj at FreeBSD.org (Rafal Jaworowski)
Date: Tue Oct 14 09:54:00 2008
Subject: svn commit: r183876 - in head/lib: libc/arm/gen libstand
Message-ID: <200810140953.m9E9rlPR001827@svn.freebsd.org>

Author: raj
Date: Tue Oct 14 09:53:47 2008
New Revision: 183876
URL: http://svn.freebsd.org/changeset/base/183876

Log:
  Let libstand(3) build on ARM.
  
  This is a pre-requisite for loader(8) + U-Boot support library on this arch.

Modified:
  head/lib/libc/arm/gen/_setjmp.S
  head/lib/libstand/Makefile

Modified: head/lib/libc/arm/gen/_setjmp.S
==============================================================================
--- head/lib/libc/arm/gen/_setjmp.S	Tue Oct 14 08:44:27 2008	(r183875)
+++ head/lib/libc/arm/gen/_setjmp.S	Tue Oct 14 09:53:47 2008	(r183876)
@@ -101,6 +101,10 @@ ENTRY(_longjmp)
 
 	/* validation failed, die die die. */
 botch:
+#if !defined(_STANDALONE)
 	bl	PIC_SYM(_C_LABEL(longjmperror), PLT)
 	bl	PIC_SYM(_C_LABEL(abort), PLT)
 	b	. - 8		/* Cannot get here */
+#else
+	b	.
+#endif

Modified: head/lib/libstand/Makefile
==============================================================================
--- head/lib/libstand/Makefile	Tue Oct 14 08:44:27 2008	(r183875)
+++ head/lib/libstand/Makefile	Tue Oct 14 09:53:47 2008	(r183876)
@@ -32,6 +32,9 @@ CFLAGS+=	-msoft-float -D_STANDALONE
 .if ${MACHINE_ARCH} == "amd64"
 CFLAGS+=	-m32 -I.
 .endif
+.if ${MACHINE_ARCH} == "arm"
+CFLAGS+=	-msoft-float -DSOFTFLOAT -D_STANDALONE
+.endif
 
 # standalone components and stuff we have modified locally
 SRCS+=	zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \
@@ -48,12 +51,17 @@ SRCS+= ntoh.c
 # string functions from libc
 .PATH: ${.CURDIR}/../libc/string
 .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "powerpc" || \
-	${MACHINE_ARCH} == "sparc64" || ${MACHINE_ARCH} == "amd64"
+	${MACHINE_ARCH} == "sparc64" || ${MACHINE_ARCH} == "amd64" || \
+	${MACHINE_ARCH} == "arm"
 SRCS+=	bcmp.c bcopy.c bzero.c ffs.c index.c memccpy.c memchr.c memcmp.c \
         memcpy.c memmove.c memset.c qdivrem.c rindex.c strcat.c strchr.c \
         strcmp.c strcpy.c strcspn.c strlen.c strncat.c strncmp.c strncpy.c \
 	strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
 .endif
+.if ${MACHINE_ARCH} == "arm"
+.PATH: ${.CURDIR}/../libc/arm/gen
+SRCS+= divsi3.S
+.endif
 .if ${MACHINE_ARCH} == "ia64"
 .PATH: ${.CURDIR}/../libc/ia64/string
 SRCS+=	bcmp.c bcopy.S bzero.S ffs.S index.c memccpy.c memchr.c memcmp.c \
From raj at FreeBSD.org  Tue Oct 14 10:11:15 2008
From: raj at FreeBSD.org (Rafal Jaworowski)
Date: Tue Oct 14 10:11:28 2008
Subject: svn commit: r183878 - in head/sys: arm/arm arm/include boot
	boot/arm boot/arm/uboot boot/common boot/ficl boot/uboot/lib
Message-ID: <200810141011.m9EABEJW002276@svn.freebsd.org>

Author: raj
Date: Tue Oct 14 10:11:14 2008
New Revision: 183878
URL: http://svn.freebsd.org/changeset/base/183878

Log:
  Initial support of loader(8) for ARM machines running U-Boot.
  
  This uses the common U-Boot support lib (sys/boot/uboot, already used on
  FreeBSD/powerpc), and assumes the underlying firmware has the modern API for
  stand-alone apps enabled in the config (CONFIG_API).
  
  Only netbooting is supported at the moment.
  
  Obtained from:	Marvell, Semihalf

Added:
  head/sys/arm/include/bootinfo.h   (contents, props changed)
  head/sys/boot/arm/uboot/
  head/sys/boot/arm/uboot/Makefile   (contents, props changed)
  head/sys/boot/arm/uboot/conf.c   (contents, props changed)
  head/sys/boot/arm/uboot/help.uboot   (contents, props changed)
  head/sys/boot/arm/uboot/ldscript.arm   (contents, props changed)
  head/sys/boot/arm/uboot/start.S   (contents, props changed)
  head/sys/boot/arm/uboot/version   (contents, props changed)
Modified:
  head/sys/arm/arm/locore.S
  head/sys/arm/include/metadata.h
  head/sys/boot/Makefile
  head/sys/boot/arm/Makefile
  head/sys/boot/common/Makefile.inc
  head/sys/boot/common/load_elf.c
  head/sys/boot/ficl/Makefile
  head/sys/boot/uboot/lib/glue.c

Modified: head/sys/arm/arm/locore.S
==============================================================================
--- head/sys/arm/arm/locore.S	Tue Oct 14 10:09:32 2008	(r183877)
+++ head/sys/arm/arm/locore.S	Tue Oct 14 10:11:14 2008	(r183878)
@@ -66,6 +66,13 @@ __FBSDID("$FreeBSD$");
 ENTRY_NP(btext)
 
 ASENTRY_NP(_start)
+
+/*
+ * Move metadata ptr to r12 (ip)
+ */
+
+	mov	ip, r0
+
 #if defined (FLASHADDR) && defined(LOADERRAMADDR)
 	/* Check if we're running from flash. */
 	ldr	r7, =FLASHADDR
@@ -170,6 +177,8 @@ mmu_done:
 	ldr	pc, .Lvirt_done
 
 virt_done:
+	mov	r0, ip			/* Load argument: metadata ptr */
+
 	mov	fp, #0			/* trace back starts here */
 	bl	_C_LABEL(initarm)	/* Off we go */
 

Added: head/sys/arm/include/bootinfo.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/arm/include/bootinfo.h	Tue Oct 14 10:11:14 2008	(r183878)
@@ -0,0 +1,72 @@
+/*-
+ * Copyright (C) 2006-2008 Semihalf, Marian Balakowicz 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
+ * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (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$
+ */
+
+#ifndef _MACHINE_BOOTINFO_H_
+#define _MACHINE_BOOTINFO_H_
+
+#if !defined(LOCORE)
+
+/* Platform hardware spec, received from loader(8) */
+
+#define BI_VERSION	1
+
+struct bi_mem_region {
+	vm_paddr_t	mem_base;
+	vm_size_t	mem_size;
+};
+
+struct bi_eth_addr {
+	u_int8_t	mac_addr[6];
+	u_int8_t	padding[2];
+};
+
+struct bootinfo {
+	u_int32_t	bi_version;
+	vm_offset_t	bi_bar_base;
+	u_int32_t	bi_cpu_clk;
+	u_int32_t	bi_bus_clk;
+	u_int8_t	bi_mem_reg_no;
+	u_int8_t	bi_eth_addr_no;
+	u_int8_t	padding[2];
+
+	u_int8_t	bi_data[1];
+	/*
+	 * The bi_data container is allocated in run time and has the
+	 * following layout:
+	 *
+	 * - bi_mem_reg_no elements of struct bi_mem_region
+	 * - bi_eth_addr_no elements of struct bi_eth_addr
+	 */
+};
+
+extern struct bootinfo *bootinfo;
+
+struct bi_mem_region *bootinfo_mr(void);
+struct bi_eth_addr *bootinfo_eth(void);
+#endif
+
+#endif /* _MACHINE_BOOTINFO_H_ */

Modified: head/sys/arm/include/metadata.h
==============================================================================
--- head/sys/arm/include/metadata.h	Tue Oct 14 10:09:32 2008	(r183877)
+++ head/sys/arm/include/metadata.h	Tue Oct 14 10:11:14 2008	(r183878)
@@ -29,6 +29,6 @@
 #ifndef _MACHINE_METADATA_H_
 #define	_MACHINE_METADATA_H_
 
-#define	MODINFOMD_SMAP		0x1001
+#define	MODINFOMD_BOOTINFO	0x1001
 
 #endif /* !_MACHINE_METADATA_H_ */

Modified: head/sys/boot/Makefile
==============================================================================
--- head/sys/boot/Makefile	Tue Oct 14 10:09:32 2008	(r183877)
+++ head/sys/boot/Makefile	Tue Oct 14 10:11:14 2008	(r183878)
@@ -22,7 +22,7 @@ SUBDIR+=		ofw
 .endif
 
 # Build U-Boot library.
-.if ${MACHINE_ARCH} == "powerpc"
+.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "arm"
 SUBDIR+=		uboot
 .endif
 

Modified: head/sys/boot/arm/Makefile
==============================================================================
--- head/sys/boot/arm/Makefile	Tue Oct 14 10:09:32 2008	(r183877)
+++ head/sys/boot/arm/Makefile	Tue Oct 14 10:11:14 2008	(r183878)
@@ -1,5 +1,5 @@
 # $FreeBSD$
 
-SUBDIR=
+SUBDIR=		uboot
 
 .include 

Added: head/sys/boot/arm/uboot/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/boot/arm/uboot/Makefile	Tue Oct 14 10:11:14 2008	(r183878)
@@ -0,0 +1,96 @@
+# $FreeBSD$
+
+PROG=		ubldr
+NEWVERSWHAT=	"U-Boot loader" ${MACHINE_ARCH}
+BINDIR?=	/boot
+INSTALLFLAGS=	-b
+NO_MAN=
+WARNS?=		1
+
+# Architecture-specific loader code
+SRCS=		start.S conf.c vers.c
+
+LOADER_DISK_SUPPORT?=	no
+LOADER_UFS_SUPPORT?=	no
+LOADER_CD9660_SUPPORT?=	no
+LOADER_EXT2FS_SUPPORT?=	no
+LOADER_NET_SUPPORT?=	yes
+LOADER_NFS_SUPPORT?=	yes
+LOADER_TFTP_SUPPORT?=	no
+LOADER_GZIP_SUPPORT?=	no
+LOADER_BZIP2_SUPPORT?=	no
+
+.if ${LOADER_DISK_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_DISK_SUPPORT
+.endif
+.if ${LOADER_UFS_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_UFS_SUPPORT
+.endif
+.if ${LOADER_CD9660_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_CD9660_SUPPORT
+.endif
+.if ${LOADER_EXT2FS_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_EXT2FS_SUPPORT
+.endif
+.if ${LOADER_GZIP_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_GZIP_SUPPORT
+.endif
+.if ${LOADER_BZIP2_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_BZIP2_SUPPORT
+.endif
+.if ${LOADER_NET_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_NET_SUPPORT
+.endif
+.if ${LOADER_NFS_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_NFS_SUPPORT
+.endif
+.if ${LOADER_TFTP_SUPPORT} == "yes"
+CFLAGS+=	-DLOADER_TFTP_SUPPORT
+.endif
+
+.if !defined(NO_FORTH)
+# Enable BootForth
+BOOT_FORTH=	yes
+CFLAGS+=	-DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/arm
+LIBFICL=	${.OBJDIR}/../../ficl/libficl.a
+.endif
+
+# Always add MI sources
+.PATH:		${.CURDIR}/../../common
+.include	"${.CURDIR}/../../common/Makefile.inc"
+CFLAGS+=	-I${.CURDIR}/../../common
+CFLAGS+=	-I.
+
+CLEANFILES+=	vers.c ${PROG}.help
+
+CFLAGS+=	-ffreestanding
+
+LDFLAGS=	-nostdlib -static -T ${.CURDIR}/ldscript.arm
+
+# Pull in common loader code
+.PATH:		${.CURDIR}/../../uboot/common
+.include	"${.CURDIR}/../../uboot/common/Makefile.inc"
+CFLAGS+=	-I${.CURDIR}/../../uboot/common
+
+# U-Boot standalone support library
+LIBUBOOT=	${.OBJDIR}/../../uboot/lib/libuboot.a
+CFLAGS+=	-I${.CURDIR}/../../uboot/lib
+CFLAGS+=	-I${.OBJDIR}/../../uboot/lib
+
+# where to get libstand from
+CFLAGS+=	-I${.CURDIR}/../../../../lib/libstand/
+
+DPADD=		${LIBFICL} ${LIBUBOOT} ${LIBSTAND}
+LDADD=		${LIBFICL} ${LIBUBOOT} -lstand
+
+vers.c:	${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
+	sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
+
+${PROG}.help: help.common help.uboot
+	cat ${.ALLSRC} | \
+	    awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
+
+.PATH: ${.CURDIR}/../../forth
+FILES=	${PROG}.help
+
+.include 

Added: head/sys/boot/arm/uboot/conf.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/boot/arm/uboot/conf.c	Tue Oct 14 10:11:14 2008	(r183878)
@@ -0,0 +1,91 @@
+/*-
+ * Copyright (c) 2008 Semihalf, Rafal Jaworowski
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include "bootstrap.h"
+#include "libuboot.h"
+
+#if defined(LOADER_NET_SUPPORT)
+#include "dev_net.h"
+#endif
+
+struct devsw *devsw[] = {
+#if defined(LOADER_DISK_SUPPORT) || defined(LOADER_CD9660_SUPPORT)
+	&uboot_disk,
+#endif
+#if defined(LOADER_NET_SUPPORT)
+	&netdev,
+#endif
+	NULL
+};
+
+struct fs_ops *file_system[] = {
+#if defined(LOADER_UFS_SUPPORT)
+	&ufs_fsops,
+#endif
+#if defined(LOADER_CD9660_SUPPORT)
+	&cd9660_fsops,
+#endif
+#if defined(LOADER_EXT2FS_SUPPORT)
+	&ext2fs_fsops,
+#endif
+#if defined(LOADER_NFS_SUPPORT)
+	&nfs_fsops,
+#endif
+#if defined(LOADER_TFTP_SUPPORT)
+	&tftp_fsops,
+#endif
+#if defined(LOADER_GZIP_SUPPORT)
+	&gzipfs_fsops,
+#endif
+#if defined(LOADER_BZIP2_SUPPORT)
+	&bzipfs_fsops,
+#endif
+	NULL
+};
+
+struct netif_driver *netif_drivers[] = {
+#if defined(LOADER_NET_SUPPORT)
+	&uboot_net,
+#endif
+	NULL,
+};
+
+struct file_format *file_formats[] = {
+	&uboot_elf,
+	NULL
+};
+
+extern struct console uboot_console;
+
+struct console *consoles[] = {
+	&uboot_console,
+	NULL
+};

Added: head/sys/boot/arm/uboot/help.uboot
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/boot/arm/uboot/help.uboot	Tue Oct 14 10:11:14 2008	(r183878)
@@ -0,0 +1 @@
+$FreeBSD$

Added: head/sys/boot/arm/uboot/ldscript.arm
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/boot/arm/uboot/ldscript.arm	Tue Oct 14 10:11:14 2008	(r183878)
@@ -0,0 +1,134 @@
+/* $FreeBSD$ */
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+SECTIONS
+{
+  /* Read-only sections, merged into text segment: */
+  . = 0x1000000 + SIZEOF_HEADERS;
+  .interp     : { *(.interp) 	}
+  .hash          : { *(.hash)		}
+  .dynsym        : { *(.dynsym)		}
+  .dynstr        : { *(.dynstr)		}
+  .gnu.version   : { *(.gnu.version)	}
+  .gnu.version_d   : { *(.gnu.version_d)	}
+  .gnu.version_r   : { *(.gnu.version_r)	}
+  .rela.text     :
+    { *(.rela.text) *(.rela.gnu.linkonce.t*) }
+  .rela.data     :
+    { *(.rela.data) *(.rela.gnu.linkonce.d*) }
+  .rela.rodata   :
+    { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
+  .rela.got      : { *(.rela.got)		}
+  .rela.got1     : { *(.rela.got1)		}
+  .rela.got2     : { *(.rela.got2)		}
+  .rela.ctors    : { *(.rela.ctors)	}
+  .rela.dtors    : { *(.rela.dtors)	}
+  .rela.init     : { *(.rela.init)	}
+  .rela.fini     : { *(.rela.fini)	}
+  .rela.bss      : { *(.rela.bss)		}
+  .rela.plt      : { *(.rela.plt)		}
+  .rela.sdata    : { *(.rela.sdata)		}
+  .rela.sbss     : { *(.rela.sbss)		}
+  .rela.sdata2   : { *(.rela.sdata2)		}
+  .rela.sbss2    : { *(.rela.sbss2)		}
+  .text      :
+  {
+    *(.text)
+    /* .gnu.warning sections are handled specially by elf32.em.  */
+    *(.gnu.warning)
+    *(.gnu.linkonce.t*)
+  } =0
+  _etext = .;
+  PROVIDE (etext = .);
+  .init      : { *(.init)    } =0
+  .fini      : { *(.fini)    } =0
+  .rodata    : { *(.rodata) *(.gnu.linkonce.r*) }
+  .rodata1   : { *(.rodata1) }
+  .sdata2    : { *(.sdata2)  }
+  .sbss2     : { *(.sbss2)   }
+  /* Adjust the address for the data segment to the next page up. */
+  . = ((. + 0x1000) & ~(0x1000 - 1));
+  .data    :
+  {
+    *(.data)
+    *(.gnu.linkonce.d*)
+    CONSTRUCTORS
+  }
+  .data1   : { *(.data1) }
+  .got1           : { *(.got1) }
+  .dynamic        : { *(.dynamic) }
+  /* Put .ctors and .dtors next to the .got2 section, so that the pointers
+     get relocated with -mrelocatable. Also put in the .fixup pointers.
+     The current compiler no longer needs this, but keep it around for 2.7.2  */
+                PROVIDE (_GOT2_START_ = .);
+  .got2           :  { *(.got2) }
+                PROVIDE (__CTOR_LIST__ = .);
+  .ctors          : { *(.ctors) }
+                PROVIDE (__CTOR_END__ = .);
+                PROVIDE (__DTOR_LIST__ = .);
+  .dtors          : { *(.dtors) }
+                PROVIDE (__DTOR_END__ = .);
+                PROVIDE (_FIXUP_START_ = .);
+  .fixup          : { *(.fixup) }
+                PROVIDE (_FIXUP_END_ = .);
+                PROVIDE (_GOT2_END_ = .);
+                PROVIDE (_GOT_START_ = .);
+  .got            : { *(.got) }
+  .got.plt        : { *(.got.plt) }
+                PROVIDE (_GOT_END_ = .);
+  /* We want the small data sections together, so single-instruction offsets
+     can access them all, and initialized data all before uninitialized, so
+     we can shorten the on-disk segment size.  */
+  .sdata     : { *(.sdata) }
+  _edata  =  .;
+  PROVIDE (edata = .);
+  .sbss      :
+  {
+    PROVIDE (__sbss_start = .);
+    *(.sbss)
+    *(.scommon)
+    *(.dynsbss)
+    PROVIDE (__sbss_end = .);
+  }
+  .plt   : { *(.plt) }
+  .bss       :
+  {
+   PROVIDE (__bss_start = .);
+   *(.dynbss)
+   *(.bss)
+   *(COMMON)
+  }
+  _end = . ;
+  PROVIDE (end = .);
+  /* Stabs debugging sections.  */
+  .stab 0 : { *(.stab) }
+  .stabstr 0 : { *(.stabstr) }
+  /* DWARF debug sections.
+     Symbols in the DWARF debugging sections are relative to the beginning
+     of the section so we begin them at 0.  */
+  /* DWARF 1 */
+  .debug          0 : { *(.debug) }
+  .line           0 : { *(.line) }
+  /* GNU DWARF 1 extensions */
+  .debug_srcinfo  0 : { *(.debug_srcinfo) }
+  .debug_sfnames  0 : { *(.debug_sfnames) }
+  /* DWARF 1.1 and DWARF 2 */
+  .debug_aranges  0 : { *(.debug_aranges) }
+  .debug_pubnames 0 : { *(.debug_pubnames) }
+  /* DWARF 2 */
+  .debug_info     0 : { *(.debug_info) }
+  .debug_abbrev   0 : { *(.debug_abbrev) }
+  .debug_line     0 : { *(.debug_line) }
+  .debug_frame    0 : { *(.debug_frame) }
+  .debug_str      0 : { *(.debug_str) }
+  .debug_loc      0 : { *(.debug_loc) }
+  .debug_macinfo  0 : { *(.debug_macinfo) }
+  /* SGI/MIPS DWARF 2 extensions */
+  .debug_weaknames 0 : { *(.debug_weaknames) }
+  .debug_funcnames 0 : { *(.debug_funcnames) }
+  .debug_typenames 0 : { *(.debug_typenames) }
+  .debug_varnames  0 : { *(.debug_varnames) }
+  /* These must appear regardless of  .  */
+}

Added: head/sys/boot/arm/uboot/start.S
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/boot/arm/uboot/start.S	Tue Oct 14 10:11:14 2008	(r183878)
@@ -0,0 +1,93 @@
+/*-
+ * Copyright (c) 2008 Semihalf, Rafal Czubak
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (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$
+ */
+
+#include 
+
+/*
+ * Entry point to the loader that U-Boot passes control to.
+ */
+	.text
+	.globl	_start
+_start:
+	/* Hint where to look for the API signature */
+	ldr	ip, =uboot_address
+	str	sp, [ip]
+
+	/* Save U-Boot's r8 */
+	ldr	ip, =saved_regs
+	str	r8, [ip, #0]
+
+	/* Start loader */
+	b	main
+
+/*
+ * syscall()
+ */
+ENTRY(syscall)
+	/* Save caller's lr */
+	ldr	ip, =saved_regs
+	str	lr, [ip, #4]
+	/* Save loader's r8 */
+	ldr	ip, =saved_regs
+	str	r8, [ip, #8]
+
+	/* Restore U-Boot's r8 */
+	ldr	ip, =saved_regs
+	ldr	r8, [ip, #0]
+	/* Call into U-Boot */
+	ldr	lr, =return_from_syscall
+	ldr	ip, =syscall_ptr
+	ldr	pc, [ip]
+
+return_from_syscall:
+	/* Restore loader's r8 */
+	ldr	ip, =saved_regs
+	ldr	r8, [ip, #8]
+	/* Restore caller's lr */
+	ldr	ip, =saved_regs
+	ldr	lr, [ip, #4]
+	/* Return to caller */
+	mov	pc, lr
+
+/*
+ * Data section
+ */
+	.data
+	.align	4
+	.globl	syscall_ptr
+syscall_ptr:
+	.long	0
+
+	.globl	uboot_address
+uboot_address:
+	.long	0
+
+saved_regs:
+	.long	0	/* U-Boot's r8 */
+	.long	0	/* Loader's r8 */
+	.long	0	/* Loader's lr */

Added: head/sys/boot/arm/uboot/version
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/boot/arm/uboot/version	Tue Oct 14 10:11:14 2008	(r183878)
@@ -0,0 +1,6 @@
+$FreeBSD$
+
+NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.  The format of this
+file is important.  Make sure the current version number is on line 6.
+
+0.5:	Initial U-Boot/arm version (netbooting only).

Modified: head/sys/boot/common/Makefile.inc
==============================================================================
--- head/sys/boot/common/Makefile.inc	Tue Oct 14 10:09:32 2008	(r183877)
+++ head/sys/boot/common/Makefile.inc	Tue Oct 14 10:11:14 2008	(r183878)
@@ -9,7 +9,7 @@ SRCS+=	load_elf32.c load_elf32_obj.c rel
 SRCS+=	load_elf64.c load_elf64_obj.c reloc_elf64.c
 .elif ${MACHINE} == "pc98"
 SRCS+=	load_elf32.c load_elf32_obj.c reloc_elf32.c
-.elif ${MACHINE_ARCH} == "powerpc"
+.elif ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "arm"
 SRCS+=	load_elf32.c reloc_elf32.c
 .elif ${MACHINE_ARCH} == "sparc64" || ${MACHINE_ARCH} == "ia64"
 SRCS+=	load_elf64.c reloc_elf64.c

Modified: head/sys/boot/common/load_elf.c
==============================================================================
--- head/sys/boot/common/load_elf.c	Tue Oct 14 10:09:32 2008	(r183877)
+++ head/sys/boot/common/load_elf.c	Tue Oct 14 10:11:14 2008	(r183878)
@@ -289,7 +289,16 @@ __elfN(loadimage)(struct preloaded_file 
 #ifdef ELF_VERBOSE
 	    printf("Converted entry 0x%08x\n", ehdr->e_entry);
 #endif
-	} else 
+	} else
+	    off = 0;
+#elif defined(__arm__)
+	if (off & 0xf0000000u) {
+	    off = -(off & 0xf0000000u);
+	    ehdr->e_entry += off;
+#ifdef ELF_VERBOSE
+	    printf("Converted entry 0x%08x\n", ehdr->e_entry);
+#endif
+	} else
 	    off = 0;
 #else
 	off = 0;		/* other archs use direct mapped kernels */

Modified: head/sys/boot/ficl/Makefile
==============================================================================
--- head/sys/boot/ficl/Makefile	Tue Oct 14 10:09:32 2008	(r183877)
+++ head/sys/boot/ficl/Makefile	Tue Oct 14 10:11:14 2008	(r183878)
@@ -14,7 +14,7 @@ CFLAGS+=	-mno-mmx -mno-3dnow -mno-sse -m
 .if ${MACHINE_ARCH} == "i386"
 CFLAGS+=	-mno-sse3
 .endif
-.if ${MACHINE_ARCH} == "powerpc"
+.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "arm"
 CFLAGS+=	-msoft-float
 .endif
 .if ${MACHINE} == "pc98"

Modified: head/sys/boot/uboot/lib/glue.c
==============================================================================
--- head/sys/boot/uboot/lib/glue.c	Tue Oct 14 10:09:32 2008	(r183877)
+++ head/sys/boot/uboot/lib/glue.c	Tue Oct 14 10:11:14 2008	(r183878)
@@ -147,7 +147,7 @@ api_search_sig(struct api_signature **si
 		uboot_address = 255 * 1024 * 1024;
 
 	sp = (void *)(uboot_address & ~0x000fffff);
-	spend = sp + 0x00100000 - API_SIG_MAGLEN;
+	spend = sp + 0x00300000 - API_SIG_MAGLEN;
 	while (sp < spend) {
 		if (!bcmp(sp, API_SIG_MAGIC, API_SIG_MAGLEN)) {
 			*sig = (struct api_signature *)sp;
From maxim at FreeBSD.org  Tue Oct 14 12:26:55 2008
From: maxim at FreeBSD.org (Maxim Konovalov)
Date: Tue Oct 14 12:27:01 2008
Subject: svn commit: r183881 - head/sys/netinet
Message-ID: <200810141226.m9ECQtPW006469@svn.freebsd.org>

Author: maxim
Date: Tue Oct 14 12:26:55 2008
New Revision: 183881
URL: http://svn.freebsd.org/changeset/base/183881

Log:
  o Reformat ipfw nat get|setsockopt code to look it  more
  style(9) compliant.  No functional changes.

Modified:
  head/sys/netinet/ip_fw2.c

Modified: head/sys/netinet/ip_fw2.c
==============================================================================
--- head/sys/netinet/ip_fw2.c	Tue Oct 14 10:23:11 2008	(r183880)
+++ head/sys/netinet/ip_fw2.c	Tue Oct 14 12:26:55 2008	(r183881)
@@ -4385,49 +4385,52 @@ ipfw_ctl(struct sockopt *sopt)
 		break;
 
 	case IP_FW_NAT_CFG:
-	{
-		if (IPFW_NAT_LOADED)
-			error = ipfw_nat_cfg_ptr(sopt);
-		else {
-			printf("IP_FW_NAT_CFG: ipfw_nat not present, please load it.\n");
-			error = EINVAL;
+		{
+			if (IPFW_NAT_LOADED)
+				error = ipfw_nat_cfg_ptr(sopt);
+			else {
+				printf("IP_FW_NAT_CFG: %s\n",
+				    "ipfw_nat not present, please load it");
+				error = EINVAL;
+			}
 		}
-	}
-	break;
+		break;
 
 	case IP_FW_NAT_DEL:
-	{
-		if (IPFW_NAT_LOADED)
-			error = ipfw_nat_del_ptr(sopt);
-		else {
-			printf("IP_FW_NAT_DEL: ipfw_nat not present, please load it.\n");
-			printf("ipfw_nat not loaded: %d\n", sopt->sopt_name);
-			error = EINVAL;
+		{
+			if (IPFW_NAT_LOADED)
+				error = ipfw_nat_del_ptr(sopt);
+			else {
+				printf("IP_FW_NAT_DEL: %s\n",
+				    "ipfw_nat not present, please load it");
+				error = EINVAL;
+			}
 		}
-	}
-	break;
+		break;
 
 	case IP_FW_NAT_GET_CONFIG:
-	{
-		if (IPFW_NAT_LOADED)
-			error = ipfw_nat_get_cfg_ptr(sopt);
-		else {
-			printf("IP_FW_NAT_GET_CFG: ipfw_nat not present, please load it.\n");
-			error = EINVAL;
+		{
+			if (IPFW_NAT_LOADED)
+				error = ipfw_nat_get_cfg_ptr(sopt);
+			else {
+				printf("IP_FW_NAT_GET_CFG: %s\n",
+				    "ipfw_nat not present, please load it");
+				error = EINVAL;
+			}
 		}
-	}
-	break;
+		break;
 
 	case IP_FW_NAT_GET_LOG:
-	{
-		if (IPFW_NAT_LOADED)
-			error = ipfw_nat_get_log_ptr(sopt);
-		else {
-			printf("IP_FW_NAT_GET_LOG: ipfw_nat not present, please load it.\n");
-			error = EINVAL;
+		{
+			if (IPFW_NAT_LOADED)
+				error = ipfw_nat_get_log_ptr(sopt);
+			else {
+				printf("IP_FW_NAT_GET_LOG: %s\n",
+				    "ipfw_nat not present, please load it");
+				error = EINVAL;
+			}
 		}
-	}
-	break;
+		break;
 
 	default:
 		printf("ipfw: ipfw_ctl invalid option %d\n", sopt->sopt_name);
From rik at inse.ru  Tue Oct 14 14:34:35 2008
From: rik at inse.ru (Roman Kurakin)
Date: Tue Oct 14 14:34:46 2008
Subject: svn commit: r183881 - head/sys/netinet
In-Reply-To: <200810141226.m9ECQtPW006469@svn.freebsd.org>
References: <200810141226.m9ECQtPW006469@svn.freebsd.org>
Message-ID: <48F4A9A5.8020605@inse.ru>

Maxim Konovalov:
> Author: maxim
> Date: Tue Oct 14 12:26:55 2008
> New Revision: 183881
> URL: http://svn.freebsd.org/changeset/base/183881
>
> Log:
>   o Reformat ipfw nat get|setsockopt code to look it  more
>   style(9) compliant.  No functional changes.
>
> Modified:
>   head/sys/netinet/ip_fw2.c
>
> Modified: head/sys/netinet/ip_fw2.c
> ==============================================================================
> --- head/sys/netinet/ip_fw2.c	Tue Oct 14 10:23:11 2008	(r183880)
> +++ head/sys/netinet/ip_fw2.c	Tue Oct 14 12:26:55 2008	(r183881)
> @@ -4385,49 +4385,52 @@ ipfw_ctl(struct sockopt *sopt)
>  		break;
>  
>  	case IP_FW_NAT_CFG:
> -	{
> -		if (IPFW_NAT_LOADED)
> -			error = ipfw_nat_cfg_ptr(sopt);
> -		else {
> -			printf("IP_FW_NAT_CFG: ipfw_nat not present, please load it.\n");
> -			error = EINVAL;
> +		{
> +			if (IPFW_NAT_LOADED)
> +				error = ipfw_nat_cfg_ptr(sopt);
> +			else {
> +				printf("IP_FW_NAT_CFG: %s\n",
> +				    "ipfw_nat not present, please load it");
> +				error = EINVAL;
> +			}
>  		}
>   
IMHO such indention does not add any usefulness, but increases indention 
level that is already very high.
Also I do not see strict contradiction to the style(9), but probably I 
am not reading the most current style(9).

rik

From nwhitehorn at FreeBSD.org  Tue Oct 14 14:54:15 2008
From: nwhitehorn at FreeBSD.org (Nathan Whitehorn)
Date: Tue Oct 14 14:54:47 2008
Subject: svn commit: r183882 - in head/sys: conf dev/powermac_nvram
	powerpc/aim powerpc/include powerpc/ofw powerpc/powermac
	powerpc/psim
Message-ID: <200810141454.m9EEsE4b009028@svn.freebsd.org>

Author: nwhitehorn
Date: Tue Oct 14 14:54:14 2008
New Revision: 183882
URL: http://svn.freebsd.org/changeset/base/183882

Log:
  Convert PowerPC AIM PCI and nexus busses to standard OFW bus interface. This
  simplifies certain device attachments (Kauai ATA, for instance), and makes
  possible others on new hardware.
  
  On G5 systems, there are several otherwise standard PCI devices
  (Serverworks SATA) that will not allow their interrupt properties to be
  written, so this information must be supplied directly from Open Firmware.
  
  Obtained from:	sparc64

Added:
  head/sys/powerpc/ofw/ofw_pcibus.c   (contents, props changed)
Deleted:
  head/sys/powerpc/include/nexusvar.h
  head/sys/powerpc/ofw/ofw_pci.c
  head/sys/powerpc/ofw/ofw_pci.h
Modified:
  head/sys/conf/files.powerpc
  head/sys/dev/powermac_nvram/powermac_nvram.c
  head/sys/powerpc/aim/nexus.c
  head/sys/powerpc/aim/ofw_machdep.c
  head/sys/powerpc/ofw/ofw_pcib_pci.c
  head/sys/powerpc/ofw/ofw_syscons.c
  head/sys/powerpc/powermac/ata_kauai.c
  head/sys/powerpc/powermac/grackle.c
  head/sys/powerpc/powermac/hrowpic.c
  head/sys/powerpc/powermac/macio.c
  head/sys/powerpc/powermac/openpic_macio.c
  head/sys/powerpc/powermac/uninorth.c
  head/sys/powerpc/powermac/uninorthvar.h
  head/sys/powerpc/psim/iobus.c
  head/sys/powerpc/psim/openpic_iobus.c

Modified: head/sys/conf/files.powerpc
==============================================================================
--- head/sys/conf/files.powerpc	Tue Oct 14 12:26:55 2008	(r183881)
+++ head/sys/conf/files.powerpc	Tue Oct 14 14:54:14 2008	(r183882)
@@ -104,7 +104,7 @@ powerpc/mpc85xx/nexus.c		optional	mpc85x
 powerpc/mpc85xx/ocpbus.c	optional	mpc85xx
 powerpc/mpc85xx/opic.c		optional	mpc85xx
 powerpc/mpc85xx/pci_ocp.c	optional	pci mpc85xx
-powerpc/ofw/ofw_pci.c		optional	pci aim
+powerpc/ofw/ofw_pcibus.c	optional	pci aim
 powerpc/ofw/ofw_pcib_pci.c	optional	pci aim
 powerpc/ofw/ofw_syscons.c	optional	sc aim
 powerpc/powermac/ata_kauai.c	optional	powermac ata

Modified: head/sys/dev/powermac_nvram/powermac_nvram.c
==============================================================================
--- head/sys/dev/powermac_nvram/powermac_nvram.c	Tue Oct 14 12:26:55 2008	(r183881)
+++ head/sys/dev/powermac_nvram/powermac_nvram.c	Tue Oct 14 14:54:14 2008	(r183882)
@@ -35,17 +35,15 @@
 #include 
 
 #include 
-#include 
+#include 
 
 #include 
 #include 
-#include 
 #include 
 #include 
 
 #include 
 
-#include 
 #include 
 
 #include 
@@ -113,10 +111,10 @@ static struct cdevsw powermac_nvram_cdev
 static int
 powermac_nvram_probe(device_t dev)
 {
-	char	*type, *compatible;
+	const char	*type, *compatible;
 
-	type = nexus_get_device_type(dev);
-	compatible = nexus_get_compatible(dev);
+	type = ofw_bus_get_type(dev);
+	compatible = ofw_bus_get_compat(dev);
 
 	if (type == NULL || compatible == NULL)
 		return ENXIO;
@@ -136,7 +134,7 @@ powermac_nvram_attach(device_t dev)
 	u_int32_t reg[2];
 	int gen0, gen1;
 
-	node = nexus_get_node(dev);
+	node = ofw_bus_get_node(dev);
 	sc = device_get_softc(dev);
 
 	if (OF_getprop(node, "reg", reg, sizeof(reg)) < 8)

Modified: head/sys/powerpc/aim/nexus.c
==============================================================================
--- head/sys/powerpc/aim/nexus.c	Tue Oct 14 12:26:55 2008	(r183881)
+++ head/sys/powerpc/aim/nexus.c	Tue Oct 14 14:54:14 2008	(r183882)
@@ -70,7 +70,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include 
@@ -90,6 +89,13 @@
 
 static MALLOC_DEFINE(M_NEXUS, "nexus", "nexus device information");
 
+enum nexus_ivars {
+	NEXUS_IVAR_NODE,
+	NEXUS_IVAR_NAME,
+	NEXUS_IVAR_DEVICE_TYPE,
+	NEXUS_IVAR_COMPATIBLE,
+};
+
 struct nexus_devinfo {
 	phandle_t	ndi_node;
 	/* Some common properties. */

Modified: head/sys/powerpc/aim/ofw_machdep.c
==============================================================================
--- head/sys/powerpc/aim/ofw_machdep.c	Tue Oct 14 12:26:55 2008	(r183881)
+++ head/sys/powerpc/aim/ofw_machdep.c	Tue Oct 14 14:54:14 2008	(r183882)
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -56,7 +57,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 
 #define	OFMEM_REGIONS	32
 static struct mem_region OFmem[OFMEM_REGIONS + 1], OFavail[OFMEM_REGIONS + 3];
@@ -282,7 +282,7 @@ OF_getetheraddr(device_t dev, u_char *ad
 {
 	phandle_t	node;
 
-	node = ofw_pci_find_node(dev);
+	node = ofw_bus_get_node(dev);
 	OF_getprop(node, "local-mac-address", addr, ETHER_ADDR_LEN);
 }
 

Modified: head/sys/powerpc/ofw/ofw_pcib_pci.c
==============================================================================
--- head/sys/powerpc/ofw/ofw_pcib_pci.c	Tue Oct 14 12:26:55 2008	(r183881)
+++ head/sys/powerpc/ofw/ofw_pcib_pci.c	Tue Oct 14 14:54:14 2008	(r183882)
@@ -35,8 +35,7 @@
 
 #include 
 #include 
-
-#include 
+#include 
 
 #include 
 #include 
@@ -46,6 +45,7 @@
 
 static int	ofw_pcib_pci_probe(device_t bus);
 static int	ofw_pcib_pci_attach(device_t bus);
+static phandle_t ofw_pcib_pci_get_node(device_t bus, device_t dev);
 
 static device_method_t ofw_pcib_pci_methods[] = {
 	/* Device interface */
@@ -72,6 +72,9 @@ static device_method_t ofw_pcib_pci_meth
 	DEVMETHOD(pcib_write_config,	pcib_write_config),
 	DEVMETHOD(pcib_route_interrupt,	pcib_route_interrupt),
 
+	/* ofw_bus interface */
+	DEVMETHOD(ofw_bus_get_node,     ofw_pcib_pci_get_node),
+
 	{0, 0}
 };
 
@@ -89,29 +92,29 @@ ofw_pcib_pci_probe(device_t dev)
 	    (pci_get_subclass(dev) != PCIS_BRIDGE_PCI)) {
 		return (ENXIO);
 	}
-	if (ofw_pci_find_node(dev) == 0) {
+
+	if (ofw_bus_get_node(dev) == 0)
 		return (ENXIO);
-	}
 
-	device_set_desc(dev, "Open Firmware PCI-PCI bridge");
-	return (-1000);
+	device_set_desc(dev, "OFW PCI-PCI bridge");
+	return (0);
 }
 
 static int
 ofw_pcib_pci_attach(device_t dev)
 {
-	phandle_t	node;
-	uint32_t	busrange[2];
-
-	node = ofw_pci_find_node(dev);
-	if (OF_getprop(node, "bus-range", busrange, sizeof(busrange)) != 8)
-		return (ENXIO);
-
 	pcib_attach_common(dev);
 
-	ofw_pci_fixup(dev, busrange[0], node);
-
 	device_add_child(dev, "pci", -1);
 
 	return (bus_generic_attach(dev));
 }
+
+phandle_t
+ofw_pcib_pci_get_node(device_t bridge, device_t dev)
+{
+	/* We have only one child, the PCI bus, so pass it our node */
+
+	return (ofw_bus_get_node(bridge));
+}
+

Added: head/sys/powerpc/ofw/ofw_pcibus.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/powerpc/ofw/ofw_pcibus.c	Tue Oct 14 14:54:14 2008	(r183882)
@@ -0,0 +1,359 @@
+/*-
+ * Copyright (c) 1994 Charles M. Hannum.  All rights reserved.
+ * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
+ * Copyright (c) 1997, Stefan Esser 
+ * Copyright (c) 2000, Michael Smith 
+ * Copyright (c) 2000, BSDi
+ * Copyright (c) 2003, Thomas Moestl 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice unmodified, this list of conditions, and the following
+ *    disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "pcib_if.h"
+#include "pci_if.h"
+
+/* Helper functions */
+static int  find_node_intr(phandle_t, u_int32_t *, u_int32_t *);
+static int  ofw_pci_find_intline(phandle_t node, uint32_t *irqs);
+static void ofw_pci_fixup_node(device_t dev, phandle_t node);
+
+/* Methods */
+static device_probe_t ofw_pcibus_probe;
+static device_attach_t ofw_pcibus_attach;
+static pci_assign_interrupt_t ofw_pcibus_assign_interrupt;
+static ofw_bus_get_devinfo_t ofw_pcibus_get_devinfo;
+
+static device_method_t ofw_pcibus_methods[] = {
+	/* Device interface */
+	DEVMETHOD(device_probe,		ofw_pcibus_probe),
+	DEVMETHOD(device_attach,	ofw_pcibus_attach),
+
+	/* PCI interface */
+	DEVMETHOD(pci_assign_interrupt, ofw_pcibus_assign_interrupt),
+
+	/* ofw_bus interface */
+	DEVMETHOD(ofw_bus_get_devinfo,	ofw_pcibus_get_devinfo),
+	DEVMETHOD(ofw_bus_get_compat,	ofw_bus_gen_get_compat),
+	DEVMETHOD(ofw_bus_get_model,	ofw_bus_gen_get_model),
+	DEVMETHOD(ofw_bus_get_name,	ofw_bus_gen_get_name),
+	DEVMETHOD(ofw_bus_get_node,	ofw_bus_gen_get_node),
+	DEVMETHOD(ofw_bus_get_type,	ofw_bus_gen_get_type),
+
+	{ 0, 0 }
+};
+
+struct ofw_pcibus_devinfo {
+	struct pci_devinfo	opd_dinfo;
+	struct ofw_bus_devinfo	opd_obdinfo;
+};
+
+static devclass_t pci_devclass;
+
+DEFINE_CLASS_1(pci, ofw_pcibus_driver, ofw_pcibus_methods, 1 /* no softc */,
+    pci_driver);
+DRIVER_MODULE(ofw_pcibus, pcib, ofw_pcibus_driver, pci_devclass, 0, 0);
+MODULE_VERSION(ofw_pcibus, 1);
+MODULE_DEPEND(ofw_pcibus, pci, 1, 1, 1);
+
+static int
+ofw_pcibus_probe(device_t dev)
+{
+	if (ofw_bus_get_node(dev) == 0)
+		return (ENXIO);
+	device_set_desc(dev, "OFW PCI bus");
+
+	return (0);
+}
+
+static int
+ofw_pcibus_attach(device_t dev)
+{
+	device_t pcib;
+	struct ofw_pci_register pcir;
+	struct ofw_pcibus_devinfo *dinfo;
+	phandle_t node, child;
+	u_int busno, domain, func, slot;
+
+	pcib = device_get_parent(dev);
+	domain = pcib_get_domain(dev);
+	busno = pcib_get_bus(dev);
+	if (bootverbose)
+		device_printf(dev, "domain=%d, physical bus=%d\n",
+		    domain, busno);
+	node = ofw_bus_get_node(dev);
+
+	for (child = OF_child(node); child != 0; child = OF_peer(child)) {
+		if (OF_getprop(child, "reg", &pcir, sizeof(pcir)) == -1)
+			continue;
+		slot = OFW_PCI_PHYS_HI_DEVICE(pcir.phys_hi);
+		func = OFW_PCI_PHYS_HI_FUNCTION(pcir.phys_hi);
+
+		/* Some OFW device trees contain dupes. */
+		if (pci_find_dbsf(domain, busno, slot, func) != NULL)
+			continue;
+
+		ofw_pci_fixup_node(pcib, child);
+
+		dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(pcib,
+		    domain, busno, slot, func, sizeof(*dinfo));
+
+		if (dinfo == NULL)
+			continue;
+
+		/* Set up OFW devinfo */
+		if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) !=
+		    0) {
+			pci_freecfg((struct pci_devinfo *)dinfo);
+			continue;
+		}
+
+		pci_add_child(dev, (struct pci_devinfo *)dinfo);
+
+		/*
+		 * Some devices don't have an intpin set, but do have
+		 * interrupts. Add them to the appropriate resource list.
+		 */
+		if (dinfo->opd_dinfo.cfg.intpin == 0) {
+			uint32_t irqs[4];
+
+			if (ofw_pci_find_intline(child, irqs) > 0)
+				resource_list_add(&dinfo->opd_dinfo.resources, 
+				    SYS_RES_IRQ, 0, irqs[0], irqs[0], 1);
+		}
+	}
+
+	return (bus_generic_attach(dev));
+}
+
+static int
+ofw_pcibus_assign_interrupt(device_t dev, device_t child)
+{
+	uint32_t irqs[4];
+
+	device_printf(child,"Assigning interrupt\n");
+
+	if (ofw_pci_find_intline(ofw_bus_get_node(child), irqs) < 0)
+		return PCI_INVALID_IRQ;
+
+	device_printf(child,"IRQ %d\n",irqs[0]);
+
+	return irqs[0];
+
+//	return (PCIB_ROUTE_INTERRUPT(device_get_parent(dev), child, intr));
+}
+
+static const struct ofw_bus_devinfo *
+ofw_pcibus_get_devinfo(device_t bus, device_t dev)
+{
+	struct ofw_pcibus_devinfo *dinfo;
+
+	dinfo = device_get_ivars(dev);
+	return (&dinfo->opd_obdinfo);
+}
+
+static void
+ofw_pci_fixup_node(device_t dev, phandle_t node)
+{
+	uint32_t	csr, intr, irqs[4];
+	struct		ofw_pci_register addr[8];
+	int		len, i;
+
+	len = OF_getprop(node, "assigned-addresses", addr, sizeof(addr));
+	if (len < (int)sizeof(struct ofw_pci_register)) {
+		return;
+	}
+
+	csr = PCIB_READ_CONFIG(dev, OFW_PCI_PHYS_HI_BUS(addr[0].phys_hi),
+	    OFW_PCI_PHYS_HI_DEVICE(addr[0].phys_hi),
+	    OFW_PCI_PHYS_HI_FUNCTION(addr[0].phys_hi), PCIR_COMMAND, 4);
+	csr &= ~(PCIM_CMD_PORTEN | PCIM_CMD_MEMEN);
+
+	for (i = 0; i < len / sizeof(struct ofw_pci_register); i++) {
+		switch (addr[i].phys_hi & OFW_PCI_PHYS_HI_SPACEMASK) {
+		case OFW_PCI_PHYS_HI_SPACE_IO:
+			csr |= PCIM_CMD_PORTEN;
+			break;
+		case OFW_PCI_PHYS_HI_SPACE_MEM32:
+			csr |= PCIM_CMD_MEMEN;
+			break;
+		}
+	}
+
+	PCIB_WRITE_CONFIG(dev, OFW_PCI_PHYS_HI_BUS(addr[0].phys_hi),
+	    OFW_PCI_PHYS_HI_DEVICE(addr[0].phys_hi),
+	    OFW_PCI_PHYS_HI_FUNCTION(addr[0].phys_hi), PCIR_COMMAND, csr, 4);
+
+	if (ofw_pci_find_intline(node, irqs) != -1) {
+		intr = PCIB_READ_CONFIG(dev,
+		    OFW_PCI_PHYS_HI_BUS(addr[0].phys_hi),
+		    OFW_PCI_PHYS_HI_DEVICE(addr[0].phys_hi),
+		    OFW_PCI_PHYS_HI_FUNCTION(addr[0].phys_hi), PCIR_INTLINE, 2);
+		intr &= ~(0xff);
+		intr |= irqs[0] & 0xff;
+		PCIB_WRITE_CONFIG(dev,
+		    OFW_PCI_PHYS_HI_BUS(addr[0].phys_hi),
+		    OFW_PCI_PHYS_HI_DEVICE(addr[0].phys_hi),
+		    OFW_PCI_PHYS_HI_FUNCTION(addr[0].phys_hi), PCIR_INTLINE,
+		    intr, 2);
+	}
+}
+
+static int
+ofw_pci_find_intline(phandle_t node, uint32_t *irqs)
+{
+	uint32_t	npintr, paddr[4];
+	struct		ofw_pci_register addr[8];
+	int		len;
+
+	len = OF_getprop(node, "assigned-addresses", addr, sizeof(addr));
+	if (len < (int)sizeof(struct ofw_pci_register)) 
+		return -1;
+	/*
+	 * Create PCI interrupt-map array element. pci-mid/pci-lo
+	 * aren't required, but the 'interrupts' property needs
+	 * to be appended
+	 */
+	npintr = 0;
+	OF_getprop(node, "interrupts", &npintr, 4);
+	paddr[0] = addr[0].phys_hi;
+	paddr[1] = 0;
+	paddr[2] = 0;
+	paddr[3] = npintr;
+
+	return find_node_intr(node, paddr, irqs);
+}
+
+static int
+find_node_intr(phandle_t node, u_int32_t *addr, u_int32_t *intr)
+{
+	phandle_t	parent, iparent;
+	int		len, mlen, match, i;
+	u_int32_t	map[160], *mp, imask[8], maskedaddr[8], icells;
+	char		name[32];
+
+	len = OF_getprop(node, "AAPL,interrupts", intr, 4);
+	if (len == 4) {
+		return (len);
+	}
+
+	parent = OF_parent(node);
+	len = OF_getprop(parent, "interrupt-map", map, sizeof(map));
+	mlen = OF_getprop(parent, "interrupt-map-mask", imask, sizeof(imask));
+
+	if (len == -1 || mlen == -1)
+		goto nomap;
+
+	memcpy(maskedaddr, addr, mlen);
+	for (i = 0; i < mlen/4; i++)
+		maskedaddr[i] &= imask[i];
+
+	mp = map;
+	while (len > mlen) {
+		match = bcmp(maskedaddr, mp, mlen);
+		mp += mlen / 4;
+		len -= mlen;
+
+		/*
+		 * We must read "#interrupt-cells" for each time because
+		 * interrupt-parent may be different.
+		 */
+		iparent = *mp++;
+		len -= 4;
+		if (OF_getprop(iparent, "#interrupt-cells", &icells, 4) != 4)
+			goto nomap;
+
+		/* Found. */
+		if (match == 0) {
+			bcopy(mp, intr, icells * 4);
+			return (icells * 4);
+		}
+
+		mp += icells;
+		len -= icells * 4;
+	}
+
+nomap:
+	/*
+	 * Check for local properties indicating interrupts
+	 */
+
+	len = OF_getprop(node, "interrupts", intr, 16);
+	if (OF_getprop(node, "interrupt-parent", &iparent, sizeof(iparent)) ==
+	   sizeof(iparent)) {
+		OF_getprop(iparent, "#interrupt-cells", &icells, sizeof(icells));
+		for (i = 0; i < len/icells/4; i++)
+			intr[i] = intr[i*icells];
+
+		return (len);
+	}
+	
+
+	/*
+	 * If the node has no interrupt property and the parent is a PCI
+	 * bridge, use the parent's interrupt.  This occurs on a PCI slot.
+	 */
+	bzero(name, sizeof(name));
+	OF_getprop(parent, "name", name, sizeof(name));
+	if (strcmp(name, "pci-bridge") == 0) {
+		len = OF_getprop(parent, "AAPL,interrupts", intr, 4);
+		if (len == 4) {
+			return (len);
+		}
+
+		/*
+		 * XXX I don't know what is the correct local address.
+		 * XXX Use the first entry for now.
+		 */
+		len = OF_getprop(parent, "interrupt-map", map, sizeof(map));
+		if (len >= 36) {
+			addr = &map[5];
+			/* XXX Use 0 for 'interrupts' for compat */
+			return (find_node_intr(parent, addr, intr));
+		}
+	}
+
+	return (-1);
+}
+

Modified: head/sys/powerpc/ofw/ofw_syscons.c
==============================================================================
--- head/sys/powerpc/ofw/ofw_syscons.c	Tue Oct 14 12:26:55 2008	(r183881)
+++ head/sys/powerpc/ofw/ofw_syscons.c	Tue Oct 14 14:54:14 2008	(r183882)
@@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 
 static int ofwfb_ignore_mmap_checks;
 SYSCTL_NODE(_hw, OID_AUTO, ofwfb, CTLFLAG_RD, 0, "ofwfb");
@@ -841,19 +840,11 @@ ofwfb_scidentify(driver_t *driver, devic
 	 * the device list
 	 */
 	child = BUS_ADD_CHILD(parent, INT_MAX, SC_DRIVER_NAME, 0);
-	if (child != NULL)
-		nexus_set_device_type(child, "syscons");
 }
 
 static int
 ofwfb_scprobe(device_t dev)
 {
-	char *name;
-
-	name = nexus_get_name(dev);
-	if (strcmp(SC_DRIVER_NAME, name) != 0)
-		return (ENXIO);
-
 	device_set_desc(dev, "System console");
 	return (sc_probe_unit(device_get_unit(dev), 
 	    device_get_flags(dev) | SC_AUTODETECT_KBD));

Modified: head/sys/powerpc/powermac/ata_kauai.c
==============================================================================
--- head/sys/powerpc/powermac/ata_kauai.c	Tue Oct 14 12:26:55 2008	(r183881)
+++ head/sys/powerpc/powermac/ata_kauai.c	Tue Oct 14 14:54:14 2008	(r183882)
@@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
-#include 
+#include 
 #include 
 
 #include 
@@ -194,11 +194,10 @@ ata_kauai_probe(device_t dev)
 {
 	struct ata_channel *ch;
 	struct ata_kauai_softc *sc;
-	u_long startp, countp;
 	u_int32_t devid;
 	phandle_t node;
-	char *compatstring = NULL;
-	int i, found, rid, status;
+	const char *compatstring = NULL;
+	int i, found, rid;
 
 	found = 0;
 	devid = pci_get_devid(dev);
@@ -212,59 +211,18 @@ ata_kauai_probe(device_t dev)
 	if (!found)
 		return (ENXIO);
 
-	node = ofw_pci_find_node(dev);
+	node = ofw_bus_get_node(dev);
 	sc = device_get_softc(dev);
 	bzero(sc, sizeof(struct ata_kauai_softc));
 	ch = &sc->sc_ch.sc_ch;
 
-	OF_getprop_alloc(node, "compatible", 1, (void **)&compatstring);
-	if (strcmp(compatstring,"shasta-ata") == 0)
+	compatstring = ofw_bus_get_compat(dev);
+	if (compatstring != NULL && strcmp(compatstring,"shasta-ata") == 0)
 		sc->shasta = 1;
 
-	free(compatstring, M_OFWPROP);
-
-
-	/*
-	 * This device seems to ignore writes to the interrupt
-	 * config register, resulting in interrupt resources
-	 * not being attached. If this is the case, use
-	 * Open Firmware to determine the irq, and then attach
-	 * the resource. This allows the ATA common code to
-	 * allocate the irq.
-	 */
-	status = bus_get_resource(dev, SYS_RES_IRQ, 0, &startp, &countp);
-	if (status == ENOENT) {
-		int *irq;
-		phandle_t iparent;
-		int icells, nintr, i;
-
-		/*
-		 * Horrible hack to handle Kauai devices that have their IRQs
-		 * set up in an utterly wrong way
-		 */
-		if (!sc->shasta)
-			bus_set_resource(dev, SYS_RES_IRQ, 0, 39, 1);
-
-		/*
-		 * For the rest of the interrupts, and the main Shasta
-		 * interrupt, get the IRQs from firmware.
-		 */
-		if (OF_getprop(node, "interrupt-parent", &iparent, 
-		    sizeof(iparent)) == sizeof(iparent)) {
-			OF_getprop(iparent, "#interrupt-cells", &icells, 
-			    sizeof(icells)) ;
-		}
-
-		nintr = OF_getprop_alloc(node, "interrupts", sizeof(*irq),
-		    (void **)&irq);
-
-		for (i = 0; i < nintr; i += icells)
-			bus_set_resource(dev, SYS_RES_IRQ, 
-			    i/icells + !sc->shasta, irq[i], 1);
-
-		free(irq, M_OFWPROP);
-	}
-
+	/* Regular Kauai controllers apparently need this hack */
+	if (!sc->shasta)
+		bus_set_resource(dev, SYS_RES_IRQ, 0, 39, 1);
 
         rid = PCIR_BARS;
 	sc->sc_memr = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, 

Modified: head/sys/powerpc/powermac/grackle.c
==============================================================================
--- head/sys/powerpc/powermac/grackle.c	Tue Oct 14 12:26:55 2008	(r183881)
+++ head/sys/powerpc/powermac/grackle.c	Tue Oct 14 14:54:14 2008	(r183882)
@@ -36,19 +36,18 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 
 #include 
 #include 
-#include 
 #include 
 #include 
 
 #include 
 
-#include 
 #include 
 
 #include 
@@ -92,6 +91,11 @@ static void		grackle_write_config(device
 static int		grackle_route_interrupt(device_t, device_t, int);
 
 /*
+ * ofw_bus interface
+ */
+static phandle_t grackle_get_node(device_t bus, device_t dev);
+
+/*
  * Local routines.
  */
 static int		grackle_enable_config(struct grackle_softc *, u_int,
@@ -122,6 +126,9 @@ static device_method_t	grackle_methods[]
 	DEVMETHOD(pcib_write_config,	grackle_write_config),
 	DEVMETHOD(pcib_route_interrupt,	grackle_route_interrupt),
 
+	/* ofw_bus interface */
+	DEVMETHOD(ofw_bus_get_node,     grackle_get_node),
+
 	{ 0, 0 }
 };
 
@@ -138,10 +145,10 @@ DRIVER_MODULE(grackle, nexus, grackle_dr
 static int
 grackle_probe(device_t dev)
 {
-	char	*type, *compatible;
+	const char	*type, *compatible;
 
-	type = nexus_get_device_type(dev);
-	compatible = nexus_get_compatible(dev);
+	type = ofw_bus_get_type(dev);
+	compatible = ofw_bus_get_compat(dev);
 
 	if (type == NULL || compatible == NULL)
 		return (ENXIO);
@@ -162,7 +169,7 @@ grackle_attach(device_t dev)
 	struct		grackle_range *rp, *io, *mem[2];
 	int		nmem, i, error;
 
-	node = nexus_get_node(dev);
+	node = ofw_bus_get_node(dev);
 	sc = device_get_softc(dev);
 
 	if (OF_getprop(node, "bus-range", busrange, sizeof(busrange)) != 8)
@@ -244,12 +251,6 @@ grackle_attach(device_t dev)
 		}
 	}
 
-	/*
-	 * Write out the correct PIC interrupt values to config space
-	 * of all devices on the bus.
-	 */
-	ofw_pci_fixup(dev, sc->sc_bus, sc->sc_node);
-
 	device_add_child(dev, "pci", device_get_unit(dev));
 	return (bus_generic_attach(dev));
 }
@@ -511,6 +512,17 @@ grackle_disable_config(struct grackle_so
 	out32rb(sc->sc_addr, 0);
 }
 
+static phandle_t
+grackle_get_node(device_t bus, device_t dev)
+{
+	struct grackle_softc *sc;
+
+	sc = device_get_softc(bus);
+	/* We only have one child, the PCI bus, which needs our own node. */
+
+	return sc->sc_node;
+}
+
 /*
  * Driver to swallow Grackle host bridges from the PCI bus side.
  */

Modified: head/sys/powerpc/powermac/hrowpic.c
==============================================================================
--- head/sys/powerpc/powermac/hrowpic.c	Tue Oct 14 12:26:55 2008	(r183881)
+++ head/sys/powerpc/powermac/hrowpic.c	Tue Oct 14 14:54:14 2008	(r183882)
@@ -48,7 +48,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 

Modified: head/sys/powerpc/powermac/macio.c
==============================================================================
--- head/sys/powerpc/powermac/macio.c	Tue Oct 14 12:26:55 2008	(r183881)
+++ head/sys/powerpc/powermac/macio.c	Tue Oct 14 14:54:14 2008	(r183882)
@@ -139,6 +139,8 @@ static struct macio_pci_dev {
 	{ 0x0022106b, "KeyLargo I/O Controller" },
 	{ 0x0025106b, "Pangea I/O Controller" },
 	{ 0x003e106b, "Intrepid I/O Controller" },
+	{ 0x0041106b, "K2 KeyLargo I/O Controller" },
+	{ 0x004f106b, "Shasta I/O Controller" },
 	{ 0, NULL }
 };
 
@@ -270,7 +272,7 @@ macio_attach(device_t dev)
 	int error, quirks;
 
 	sc = device_get_softc(dev);
-	root = sc->sc_node = OF_finddevice("mac-io");
+	root = sc->sc_node = ofw_bus_get_node(dev);
 	
 	/*
 	 * Locate the device node and it's base address

Modified: head/sys/powerpc/powermac/openpic_macio.c
==============================================================================
--- head/sys/powerpc/powermac/openpic_macio.c	Tue Oct 14 12:26:55 2008	(r183881)
+++ head/sys/powerpc/powermac/openpic_macio.c	Tue Oct 14 14:54:14 2008	(r183882)
@@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 

Modified: head/sys/powerpc/powermac/uninorth.c
==============================================================================
--- head/sys/powerpc/powermac/uninorth.c	Tue Oct 14 12:26:55 2008	(r183881)
+++ head/sys/powerpc/powermac/uninorth.c	Tue Oct 14 14:54:14 2008	(r183882)
@@ -34,19 +34,18 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 
 #include 
 #include 
-#include 
 #include 
 #include 
 
 #include 
 
-#include 
 #include 
 
 #include 
@@ -84,6 +83,12 @@ static void		uninorth_write_config(devic
 static int		uninorth_route_interrupt(device_t, device_t, int);
 
 /*
+ * OFW Bus interface
+ */
+
+static phandle_t	 uninorth_get_node(device_t bus, device_t dev);
+
+/*
  * Local routines.
  */
 static int		uninorth_enable_config(struct uninorth_softc *, u_int,
@@ -112,6 +117,9 @@ static device_method_t	uninorth_methods[
 	DEVMETHOD(pcib_write_config,	uninorth_write_config),
 	DEVMETHOD(pcib_route_interrupt,	uninorth_route_interrupt),
 
+	/* ofw_bus interface */
+	DEVMETHOD(ofw_bus_get_node,     uninorth_get_node),
+
 	{ 0, 0 }
 };
 
@@ -128,32 +136,40 @@ DRIVER_MODULE(uninorth, nexus, uninorth_
 static int
 uninorth_probe(device_t dev)
 {
-	char	*type, *compatible;
+	const char	*type, *compatible;
 
-	type = nexus_get_device_type(dev);
-	compatible = nexus_get_compatible(dev);
+	type = ofw_bus_get_type(dev);
+	compatible = ofw_bus_get_compat(dev);
 
 	if (type == NULL || compatible == NULL)
 		return (ENXIO);
 
-	if (strcmp(type, "pci") != 0 || strcmp(compatible, "uni-north") != 0)
+	if (strcmp(type, "pci") != 0)
 		return (ENXIO);
 
-	device_set_desc(dev, "Apple UniNorth Host-PCI bridge");
-	return (0);
+	if (strcmp(compatible, "uni-north") == 0) {
+		device_set_desc(dev, "Apple UniNorth Host-PCI bridge");
+		return (0);
+	} else if (strcmp(compatible,"u3-agp") == 0) {
+		device_set_desc(dev, "Apple U3 Host-AGP bridge");
+		return (0);
+	}
+	
+	return (ENXIO);
 }
 
 static int
 uninorth_attach(device_t dev)
 {
 	struct		uninorth_softc *sc;
+	const char	*compatible;
 	phandle_t	node;
 	phandle_t	child;
 	u_int32_t	reg[2], busrange[2];
 	struct		uninorth_range *rp, *io, *mem[2];
 	int		nmem, i, error;
 
-	node = nexus_get_node(dev);
+	node = ofw_bus_get_node(dev);
 	sc = device_get_softc(dev);
 
 	if (OF_getprop(node, "reg", reg, sizeof(reg)) < 8)
@@ -162,15 +178,48 @@ uninorth_attach(device_t dev)
 	if (OF_getprop(node, "bus-range", busrange, sizeof(busrange)) != 8)
 		return (ENXIO);
 
+	sc->sc_u3 = 0;
+	compatible = ofw_bus_get_compat(dev);
+	if (strcmp(compatible,"u3-agp") == 0)
+		sc->sc_u3 = 1;
+
 	sc->sc_dev = dev;
 	sc->sc_node = node;
-	sc->sc_addr = (vm_offset_t)pmap_mapdev(reg[0] + 0x800000, PAGE_SIZE);
-	sc->sc_data = (vm_offset_t)pmap_mapdev(reg[0] + 0xc00000, PAGE_SIZE);
+	if (sc->sc_u3) {
+	   sc->sc_addr = (vm_offset_t)pmap_mapdev(reg[1] + 0x800000, PAGE_SIZE);
+	   sc->sc_data = (vm_offset_t)pmap_mapdev(reg[1] + 0xc00000, PAGE_SIZE);
+	} else {
+	   sc->sc_addr = (vm_offset_t)pmap_mapdev(reg[0] + 0x800000, PAGE_SIZE);
+	   sc->sc_data = (vm_offset_t)pmap_mapdev(reg[0] + 0xc00000, PAGE_SIZE);
+	}
 	sc->sc_bus = busrange[0];
 
 	bzero(sc->sc_range, sizeof(sc->sc_range));
-	sc->sc_nrange = OF_getprop(node, "ranges", sc->sc_range,
-	    sizeof(sc->sc_range));
+	if (sc->sc_u3) {
+		/*
+		 * On Apple U3 systems, we have an otherwise standard
+		 * Uninorth controller driving AGP. The one difference
+		 * is that it uses a new PCI ranges format, so do the
+		 * translation.
+		 */
+
+		struct uninorth_range64 range64[6];
+		bzero(range64, sizeof(range64));
+
+		sc->sc_nrange = OF_getprop(node, "ranges", range64,
+		    sizeof(range64));
+		for (i = 0; range64[i].pci_hi != 0; i++) {
+			sc->sc_range[i].pci_hi = range64[i].pci_hi;
+			sc->sc_range[i].pci_mid = range64[i].pci_mid;
+			sc->sc_range[i].pci_lo = range64[i].pci_lo;
+			sc->sc_range[i].host = range64[i].host_lo;
+			sc->sc_range[i].size_hi = range64[i].size_hi;
+			sc->sc_range[i].size_lo = range64[i].size_lo;
+		}
+	} else {
+		sc->sc_nrange = OF_getprop(node, "ranges", sc->sc_range,
+		    sizeof(sc->sc_range));
+	}
 
 	if (sc->sc_nrange == -1) {
 		device_printf(dev, "could not get ranges\n");
@@ -245,13 +294,6 @@ uninorth_attach(device_t dev)
 		}
 	}
 
-	/*
-	 * Write out the correct PIC interrupt values to config space
-	 * of all devices on the bus. This has to be done after the GEM
-	 * cell is enabled above.
-	 */
-	ofw_pci_fixup(dev, sc->sc_bus, node);
-
 	device_add_child(dev, "pci", device_get_unit(dev));
 	return (bus_generic_attach(dev));
 }
@@ -275,7 +317,7 @@ uninorth_read_config(device_t dev, u_int
 
 	if (uninorth_enable_config(sc, bus, slot, func, reg) != 0) {
 		switch (width) {
-		case 1:
+		case 1: 
 			return (in8rb(caoff));
 			break;
 		case 2:
@@ -467,6 +509,17 @@ uninorth_enable_config(struct uninorth_s
 	return (1);
 }
 
+static phandle_t
+uninorth_get_node(device_t bus, device_t dev)
+{
+	struct uninorth_softc *sc;
+
+	sc = device_get_softc(bus);
+	/* We only have one child, the PCI bus, which needs our own node. */
+
+	return sc->sc_node;
+}
+
 /*
  * Driver to swallow UniNorth host bridges from the PCI bus side.
  */
@@ -533,9 +586,9 @@ unin_enable_gmac(void)
 static int
 unin_chip_probe(device_t dev)
 {
-	char	*name;
+	const char	*name;
 
-	name = nexus_get_name(dev);
+	name = ofw_bus_get_name(dev);
 
 	if (name == NULL)

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
From max at love2party.net  Tue Oct 14 15:01:42 2008
From: max at love2party.net (Max Laier)
Date: Tue Oct 14 15:01:52 2008
Subject: svn commit: r183881 - head/sys/netinet
In-Reply-To: <48F4A9A5.8020605@inse.ru>
References: <200810141226.m9ECQtPW006469@svn.freebsd.org>
	<48F4A9A5.8020605@inse.ru>
Message-ID: <200810141649.04834.max@love2party.net>

On Tuesday 14 October 2008 16:16:05 Roman Kurakin wrote:
> Maxim Konovalov:
> > Author: maxim
> > Date: Tue Oct 14 12:26:55 2008
> > New Revision: 183881
> > URL: http://svn.freebsd.org/changeset/base/183881
> >
> > Log:
> >   o Reformat ipfw nat get|setsockopt code to look it  more
> >   style(9) compliant.  No functional changes.
> >
> > Modified:
> >   head/sys/netinet/ip_fw2.c
> >
> > Modified: head/sys/netinet/ip_fw2.c
> > =========================================================================
> >===== --- head/sys/netinet/ip_fw2.c	Tue Oct 14 10:23:11 2008	(r183880) +++
> > head/sys/netinet/ip_fw2.c	Tue Oct 14 12:26:55 2008	(r183881) @@ -4385,49
> > +4385,52 @@ ipfw_ctl(struct sockopt *sopt)
> >  		break;
> >
> >  	case IP_FW_NAT_CFG:
> > -	{
> > -		if (IPFW_NAT_LOADED)
> > -			error = ipfw_nat_cfg_ptr(sopt);
> > -		else {
> > -			printf("IP_FW_NAT_CFG: ipfw_nat not present, please load it.\n");
> > -			error = EINVAL;
> > +		{
> > +			if (IPFW_NAT_LOADED)
> > +				error = ipfw_nat_cfg_ptr(sopt);
> > +			else {
> > +				printf("IP_FW_NAT_CFG: %s\n",
> > +				    "ipfw_nat not present, please load it");
> > +				error = EINVAL;
> > +			}
> >  		}
>
> IMHO such indention does not add any usefulness, but increases indention
> level that is already very high.
> Also I do not see strict contradiction to the style(9), but probably I
> am not reading the most current style(9).

The additional scope is absolutely unnecessary here and should be dropped - 
IMHO.  See case IP_FW_RESETLOG and above.

-- 
/"\  Best regards,                      | mlaier@freebsd.org
\ /  Max Laier                          | ICQ #67774661
 X   http://pf4freebsd.love2party.net/  | mlaier@EFnet
/ \  ASCII Ribbon Campaign              | Against HTML Mail and News
From thompsa at FreeBSD.org  Tue Oct 14 15:08:25 2008
From: thompsa at FreeBSD.org (Andrew Thompson)
Date: Tue Oct 14 15:08:37 2008
Subject: svn commit: r183868 - head/sys/dev/usb
In-Reply-To: <200810140745.m9E7jBai099067@svn.freebsd.org>
References: <200810140745.m9E7jBai099067@svn.freebsd.org>
Message-ID: <20081014144244.GA94595@citylink.fud.org.nz>

On Tue, Oct 14, 2008 at 07:45:11AM +0000, Nick Hibma wrote:
> Author: n_hibma
> Date: Tue Oct 14 07:45:11 2008
> New Revision: 183868
> URL: http://svn.freebsd.org/changeset/base/183868
> 
> Log:
>   - Fix the naming of the MC950D device.
>   - Remove the (unimplemented) U3GFL_EJECT quirk as this won't be implemented in
>     the u3g driver anyway (most probably as an entry in devd.conf)
> 
> Modified:
>   head/sys/dev/usb/u3g.c
>   head/sys/dev/usb/usbdevs
> 
> Modified: head/sys/dev/usb/usbdevs
> ==============================================================================
> --- head/sys/dev/usb/usbdevs	Tue Oct 14 07:24:18 2008	(r183867)
> +++ head/sys/dev/usb/usbdevs	Tue Oct 14 07:45:11 2008	(r183868)
> @@ -1839,7 +1839,7 @@ product NOVATEL X950D		0x1450	Merlin X95
>  product NOVATEL ES620		0x2100	ES620 CDMA
>  product NOVATEL U720		0x2110	Merlin U720
>  product NOVATEL U727		0x4100	Merlin U727 CDMA
> -product NOVATEL U950D		0x4400	Novatel MC950D HSUPA
> +product NOVATEL MC950D		0x4400	Novatel MC950D HSUPA
>  product NOVATEL ZEROCD		0x5010	Novatel ZeroCD
>  product NOVATEL2 FLEXPACKGPS	0x0100	NovAtel FlexPack GPS receiver

Once an entry is in usbdevs please do _not_ change it, even if its not
perfect. This will create conflicts for 3rd parties (me).


cheers,
Andrew
From n_hibma at FreeBSD.org  Tue Oct 14 15:19:02 2008
From: n_hibma at FreeBSD.org (Nick Hibma)
Date: Tue Oct 14 15:19:14 2008
Subject: svn commit: r183883 - head/sys/dev/usb
Message-ID: <200810141519.m9EFJ2Mp009565@svn.freebsd.org>

Author: n_hibma
Date: Tue Oct 14 15:19:02 2008
New Revision: 183883
URL: http://svn.freebsd.org/changeset/base/183883

Log:
  Add back in the (incorrect) entry for the MC950D, as requested by Andrew
  Thompson. They should not be removed in support of 3rd party software.

Modified:
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/usbdevs
==============================================================================
--- head/sys/dev/usb/usbdevs	Tue Oct 14 14:54:14 2008	(r183882)
+++ head/sys/dev/usb/usbdevs	Tue Oct 14 15:19:02 2008	(r183883)
@@ -1839,6 +1839,7 @@ product NOVATEL X950D		0x1450	Merlin X95
 product NOVATEL ES620		0x2100	ES620 CDMA
 product NOVATEL U720		0x2110	Merlin U720
 product NOVATEL U727		0x4100	Merlin U727 CDMA
+product NOVATEL U950D		0x4400	Novatel MC950D HSUPA
 product NOVATEL MC950D		0x4400	Novatel MC950D HSUPA
 product NOVATEL ZEROCD		0x5010	Novatel ZeroCD
 product NOVATEL2 FLEXPACKGPS	0x0100	NovAtel FlexPack GPS receiver
From n_hibma at FreeBSD.org  Tue Oct 14 15:30:18 2008
From: n_hibma at FreeBSD.org (Nick Hibma)
Date: Tue Oct 14 15:30:29 2008
Subject: svn commit: r183885 - head/share/man/man4
Message-ID: <200810141530.m9EFUHNn009874@svn.freebsd.org>

Author: n_hibma
Date: Tue Oct 14 15:30:17 2008
New Revision: 183885
URL: http://svn.freebsd.org/changeset/base/183885

Log:
  Correct the name of the device.

Modified:
  head/share/man/man4/u3g.4

Modified: head/share/man/man4/u3g.4
==============================================================================
--- head/share/man/man4/u3g.4	Tue Oct 14 15:22:36 2008	(r183884)
+++ head/share/man/man4/u3g.4	Tue Oct 14 15:30:17 2008	(r183885)
@@ -72,7 +72,7 @@ Huawei E220 (E270?)
 .It
 Huawei Mobile
 .It
-Novatal U950D
+Novatal MC950D
 .El
 (See /sys/dev/u3g.c for the complete list of supported cards for each vendor
 mentioned above).
From sam at freebsd.org  Tue Oct 14 16:13:40 2008
From: sam at freebsd.org (Sam Leffler)
Date: Tue Oct 14 16:13:46 2008
Subject: svn commit: r183873 - head/sys/arm/conf
In-Reply-To: <200810140818.m9E8IRLX099905@svn.freebsd.org>
References: <200810140818.m9E8IRLX099905@svn.freebsd.org>
Message-ID: <48F4C26B.7060109@freebsd.org>

Rafal Jaworowski wrote:
> Author: raj
> Date: Tue Oct 14 08:18:27 2008
> New Revision: 183873
> URL: http://svn.freebsd.org/changeset/base/183873
>
> Log:
>   Add kernel config files for Marvell development boards.
>   
>   FreeBSD 8-CURRENT was tested and run successfully on the following eval
>   boards and devices :
>   
>     * DB-88F5182, DB-88F5281 (Orion based)
>   
>     * DB-88F6281, RD-88F6281 (Kirkwood based)
>   
>     * DB-78100 (Discovery based)
>   
>   For more detailed info on build instructions and other examples please refer
>   to http://wiki.freebsd.org/FreeBSDMarvell
>   
Some of these boards/SoC's are bi-endian can you note which byte 
order(s) have been tested?  Thanks.

    Sam

From sam at FreeBSD.org  Tue Oct 14 16:27:53 2008
From: sam at FreeBSD.org (Sam Leffler)
Date: Tue Oct 14 16:28:04 2008
Subject: svn commit: r183886 - head/sys/arm/xscale/ixp425
Message-ID: <200810141627.m9EGRqhN010887@svn.freebsd.org>

Author: sam
Date: Tue Oct 14 16:27:52 2008
New Revision: 183886
URL: http://svn.freebsd.org/changeset/base/183886

Log:
  correct sizeof calculation
  
  PR:		arm/128095
  Submitted by:	Henning Petersen
  MFC after:	1 week

Modified:
  head/sys/arm/xscale/ixp425/if_npe.c

Modified: head/sys/arm/xscale/ixp425/if_npe.c
==============================================================================
--- head/sys/arm/xscale/ixp425/if_npe.c	Tue Oct 14 15:30:17 2008	(r183885)
+++ head/sys/arm/xscale/ixp425/if_npe.c	Tue Oct 14 16:27:52 2008	(r183886)
@@ -448,7 +448,7 @@ npe_dma_setup(struct npe_softc *sc, stru
 {
 	int error, i;
 
-	memset(dma, 0, sizeof(dma));
+	memset(dma, 0, sizeof(*dma));
 
 	dma->name = name;
 	dma->nbuf = nbuf;
From raj at semihalf.com  Tue Oct 14 16:30:08 2008
From: raj at semihalf.com (Rafal Jaworowski)
Date: Tue Oct 14 16:30:20 2008
Subject: svn commit: r183873 - head/sys/arm/conf
In-Reply-To: <48F4C26B.7060109@freebsd.org>
References: <200810140818.m9E8IRLX099905@svn.freebsd.org>
	<48F4C26B.7060109@freebsd.org>
Message-ID: <48F4C41D.90603@semihalf.com>

Sam Leffler wrote:
> Rafal Jaworowski wrote:
>> Author: raj
>> Date: Tue Oct 14 08:18:27 2008
>> New Revision: 183873
>> URL: http://svn.freebsd.org/changeset/base/183873
>>
>> Log:
>>   Add kernel config files for Marvell development boards.
>>     FreeBSD 8-CURRENT was tested and run successfully on the following
>> eval
>>   boards and devices :
>>       * DB-88F5182, DB-88F5281 (Orion based)
>>       * DB-88F6281, RD-88F6281 (Kirkwood based)
>>       * DB-78100 (Discovery based)
>>     For more detailed info on build instructions and other examples
>> please refer
>>   to http://wiki.freebsd.org/FreeBSDMarvell
>>   
> Some of these boards/SoC's are bi-endian can you note which byte
> order(s) have been tested?  Thanks.

Good point. Only LE mode has been tested so far. I'll add a note about this on
the wiki page.

Rafal
From maxim at FreeBSD.org  Tue Oct 14 17:47:29 2008
From: maxim at FreeBSD.org (Maxim Konovalov)
Date: Tue Oct 14 17:47:36 2008
Subject: svn commit: r183887 - head/sys/netinet
Message-ID: <200810141747.m9EHlTWi012291@svn.freebsd.org>

Author: maxim
Date: Tue Oct 14 17:47:29 2008
New Revision: 183887
URL: http://svn.freebsd.org/changeset/base/183887

Log:
  o Remove unnecessary parentheses and restore identation.
  
  Prodded by:	mlaier

Modified:
  head/sys/netinet/ip_fw2.c

Modified: head/sys/netinet/ip_fw2.c
==============================================================================
--- head/sys/netinet/ip_fw2.c	Tue Oct 14 16:27:52 2008	(r183886)
+++ head/sys/netinet/ip_fw2.c	Tue Oct 14 17:47:29 2008	(r183887)
@@ -4385,50 +4385,42 @@ ipfw_ctl(struct sockopt *sopt)
 		break;
 
 	case IP_FW_NAT_CFG:
-		{
-			if (IPFW_NAT_LOADED)
-				error = ipfw_nat_cfg_ptr(sopt);
-			else {
-				printf("IP_FW_NAT_CFG: %s\n",
-				    "ipfw_nat not present, please load it");
-				error = EINVAL;
-			}
+		if (IPFW_NAT_LOADED)
+			error = ipfw_nat_cfg_ptr(sopt);
+		else {
+			printf("IP_FW_NAT_CFG: %s\n",
+			    "ipfw_nat not present, please load it");
+			error = EINVAL;
 		}
 		break;
 
 	case IP_FW_NAT_DEL:
-		{
-			if (IPFW_NAT_LOADED)
-				error = ipfw_nat_del_ptr(sopt);
-			else {
-				printf("IP_FW_NAT_DEL: %s\n",
-				    "ipfw_nat not present, please load it");
-				error = EINVAL;
-			}
+		if (IPFW_NAT_LOADED)
+			error = ipfw_nat_del_ptr(sopt);
+		else {
+			printf("IP_FW_NAT_DEL: %s\n",
+			    "ipfw_nat not present, please load it");
+			error = EINVAL;
 		}
 		break;
 
 	case IP_FW_NAT_GET_CONFIG:
-		{
-			if (IPFW_NAT_LOADED)
-				error = ipfw_nat_get_cfg_ptr(sopt);
-			else {
-				printf("IP_FW_NAT_GET_CFG: %s\n",
-				    "ipfw_nat not present, please load it");
-				error = EINVAL;
-			}
+		if (IPFW_NAT_LOADED)
+			error = ipfw_nat_get_cfg_ptr(sopt);
+		else {
+			printf("IP_FW_NAT_GET_CFG: %s\n",
+			    "ipfw_nat not present, please load it");
+			error = EINVAL;
 		}
 		break;
 
 	case IP_FW_NAT_GET_LOG:
-		{
-			if (IPFW_NAT_LOADED)
-				error = ipfw_nat_get_log_ptr(sopt);
-			else {
-				printf("IP_FW_NAT_GET_LOG: %s\n",
-				    "ipfw_nat not present, please load it");
-				error = EINVAL;
-			}
+		if (IPFW_NAT_LOADED)
+			error = ipfw_nat_get_log_ptr(sopt);
+		else {
+			printf("IP_FW_NAT_GET_LOG: %s\n",
+			    "ipfw_nat not present, please load it");
+			error = EINVAL;
 		}
 		break;
 
From dumbbell at FreeBSD.org  Tue Oct 14 17:48:36 2008
From: dumbbell at FreeBSD.org (Jean-Sebastien Pedron)
Date: Tue Oct 14 17:48:43 2008
Subject: svn commit: r183888 - head/sys/dev/atkbdc
Message-ID: <200810141748.m9EHma9d012354@svn.freebsd.org>

Author: dumbbell
Date: Tue Oct 14 17:48:36 2008
New Revision: 183888
URL: http://svn.freebsd.org/changeset/base/183888

Log:
  Rewrite Synaptics touchpads support with the following goals in mind:
      o  better quality of the movement smoothing
      o  more features such as tap-hold and virtual scrolling
  
  Support must still be enabled with this line in your /boot/loader.conf:
      hw.psm.synaptics_support="1"
  
  The following sysctls were removed:
      hw.psm.synaptics.low_speed_threshold
      hw.psm.synaptics.min_movement
      hw.psm.synaptics.squelch_level
  
  An overview of this new driver and a short documentation about the added
  sysctls is available on the wiki:
  http://wiki.freebsd.org/SynapticsTouchpad

Modified:
  head/sys/dev/atkbdc/psm.c

Modified: head/sys/dev/atkbdc/psm.c
==============================================================================
--- head/sys/dev/atkbdc/psm.c	Tue Oct 14 17:47:29 2008	(r183887)
+++ head/sys/dev/atkbdc/psm.c	Tue Oct 14 17:48:36 2008	(r183888)
@@ -163,15 +163,101 @@ typedef struct packetbuf {
 #define	PSM_PACKETQUEUE	128
 #endif
 
+enum {
+	SYNAPTICS_SYSCTL_MIN_PRESSURE,
+	SYNAPTICS_SYSCTL_MAX_PRESSURE,
+	SYNAPTICS_SYSCTL_MAX_WIDTH,
+	SYNAPTICS_SYSCTL_MARGIN_TOP,
+	SYNAPTICS_SYSCTL_MARGIN_RIGHT,
+	SYNAPTICS_SYSCTL_MARGIN_BOTTOM,
+	SYNAPTICS_SYSCTL_MARGIN_LEFT,
+	SYNAPTICS_SYSCTL_NA_TOP,
+	SYNAPTICS_SYSCTL_NA_RIGHT,
+	SYNAPTICS_SYSCTL_NA_BOTTOM,
+	SYNAPTICS_SYSCTL_NA_LEFT,
+	SYNAPTICS_SYSCTL_WINDOW_MIN,
+	SYNAPTICS_SYSCTL_WINDOW_MAX,
+	SYNAPTICS_SYSCTL_MULTIPLICATOR,
+	SYNAPTICS_SYSCTL_WEIGHT_CURRENT,
+	SYNAPTICS_SYSCTL_WEIGHT_PREVIOUS,
+	SYNAPTICS_SYSCTL_WEIGHT_PREVIOUS_NA,
+	SYNAPTICS_SYSCTL_WEIGHT_LEN_SQUARED,
+	SYNAPTICS_SYSCTL_DIV_MIN,
+	SYNAPTICS_SYSCTL_DIV_MAX,
+	SYNAPTICS_SYSCTL_DIV_MAX_NA,
+	SYNAPTICS_SYSCTL_DIV_LEN,
+	SYNAPTICS_SYSCTL_TAP_MAX_DELTA,
+	SYNAPTICS_SYSCTL_TAP_MIN_QUEUE,
+	SYNAPTICS_SYSCTL_TAPHOLD_TIMEOUT,
+	SYNAPTICS_SYSCTL_VSCROLL_HOR_AREA,
+	SYNAPTICS_SYSCTL_VSCROLL_VER_AREA,
+	SYNAPTICS_SYSCTL_VSCROLL_MIN_DELTA,
+	SYNAPTICS_SYSCTL_VSCROLL_DIV_MIN,
+	SYNAPTICS_SYSCTL_VSCROLL_DIV_MAX
+};
+
 typedef struct synapticsinfo {
-	struct sysctl_ctx_list	sysctl_ctx;
+	struct sysctl_ctx_list	 sysctl_ctx;
 	struct sysctl_oid	*sysctl_tree;
-	int			directional_scrolls;
-	int			low_speed_threshold;
-	int			min_movement;
-	int			squelch_level;
+	int			 directional_scrolls;
+	int			 min_pressure;
+	int			 max_pressure;
+	int			 max_width;
+	int			 margin_top;
+	int			 margin_right;
+	int			 margin_bottom;
+	int			 margin_left;
+	int			 na_top;
+	int			 na_right;
+	int			 na_bottom;
+	int			 na_left;
+	int			 window_min;
+	int			 window_max;
+	int			 multiplicator;
+	int			 weight_current;
+	int			 weight_previous;
+	int			 weight_previous_na;
+	int			 weight_len_squared;
+	int			 div_min;
+	int			 div_max;
+	int			 div_max_na;
+	int			 div_len;
+	int			 tap_max_delta;
+	int			 tap_min_queue;
+	int			 taphold_timeout;
+	int			 vscroll_ver_area;
+	int			 vscroll_hor_area;
+	int			 vscroll_min_delta;
+	int			 vscroll_div_min;
+	int			 vscroll_div_max;
 } synapticsinfo_t;
 
+typedef struct synapticspacket {
+	int			x;
+	int			y;
+} synapticspacket_t;
+
+#define	SYNAPTICS_PACKETQUEUE 10
+#define SYNAPTICS_QUEUE_CURSOR(x)					\
+	(x + SYNAPTICS_PACKETQUEUE) % SYNAPTICS_PACKETQUEUE
+
+typedef struct synapticsaction {
+	synapticspacket_t	queue[SYNAPTICS_PACKETQUEUE];
+	int			queue_len;
+	int			queue_cursor;
+	int			window_min;
+	int			start_x;
+	int			start_y;
+	int			avg_dx;
+	int			avg_dy;
+	int			squelch_x;
+	int			squelch_y;
+	int			fingers_nb;
+	int			tap_button;
+	int			in_taphold;
+	int			in_vscroll;
+} synapticsaction_t;
+
 /* driver control block */
 struct psm_softc {		/* Driver status information */
 	int		unit;
@@ -185,6 +271,7 @@ struct psm_softc {		/* Driver status inf
 	mousehw_t	hw;		/* hardware information */
 	synapticshw_t	synhw;		/* Synaptics hardware information */
 	synapticsinfo_t	syninfo;	/* Synaptics configuration */
+	synapticsaction_t synaction;	/* Synaptics action context */
 	mousemode_t	mode;		/* operation mode */
 	mousemode_t	dflt_mode;	/* default operation mode */
 	mousestatus_t	status;		/* accumulated mouse movement */
@@ -781,6 +868,35 @@ doopen(struct psm_softc *sc, int command
 {
 	int stat[3];
 
+	/*
+	 * FIXME: Synaptics TouchPad seems to go back to Relative Mode with
+	 * no obvious reason. Thus we check the current mode and restore the
+	 * Absolute Mode if it was cleared.
+	 *
+	 * The previous hack at the end of psmprobe() wasn't efficient when
+	 * moused(8) was restarted.
+	 *
+	 * A Reset (FF) or Set Defaults (F6) command would clear the
+	 * Absolute Mode bit. But a verbose boot or debug.psm.loglevel=5
+	 * doesn't show any evidence of such a command.
+	 */
+	if (sc->hw.model == MOUSE_MODEL_SYNAPTICS) {
+		mouse_ext_command(sc->kbdc, 1);
+		get_mouse_status(sc->kbdc, stat, 0, 3);
+		if (stat[1] == 0x47 && stat[2] == 0x40) {
+			/* Set the mode byte -- request wmode where
+			 * available */
+			if (sc->synhw.capExtended)
+				mouse_ext_command(sc->kbdc, 0xc1);
+			else
+				mouse_ext_command(sc->kbdc, 0xc0);
+			set_mouse_sampling_rate(sc->kbdc, 20);
+			VLOG(5, (LOG_DEBUG, "psm%d: Synaptis Absolute Mode "
+			    "hopefully restored\n",
+			    sc->unit));
+		}
+	}
+
 	/* enable the mouse device */
 	if (!enable_aux_dev(sc->kbdc)) {
 		/* MOUSE ERROR: failed to enable the mouse because:
@@ -1272,15 +1388,6 @@ psmprobe(device_t dev)
 		endprobe(ENXIO);
 	}
 
-	/*
-	 * Synaptics TouchPad seems to go back to Relative Mode after
-	 * the previous set_controller_command_byte() call; by issueing
-	 * a Read Mode Byte command, the touchpad is in Absolute Mode
-	 * again.
-	 */
-	if (sc->hw.model == MOUSE_MODEL_SYNAPTICS)
-		mouse_ext_command(sc->kbdc, 1);
-
 	/* done */
 	kbdc_set_device_mask(sc->kbdc, mask | KBD_AUX_CONTROL_BITS);
 	kbdc_lock(sc->kbdc, FALSE);
@@ -2398,7 +2505,7 @@ proc_synaptics(struct psm_softc *sc, pac
 {
 	static int touchpad_buttons;
 	static int guest_buttons;
-	int w, x0, y0, xavg, yavg, xsensitivity, ysensitivity, sensitivity = 0;
+	int w, x0, y0;
 
 	/* TouchPad PS/2 absolute mode message format
 	 *
@@ -2418,7 +2525,7 @@ proc_synaptics(struct psm_softc *sc, pac
 	 *  U: up button
 	 *  W: "wrist" value
 	 *  X: x position
-	 *  Y: x position
+	 *  Y: y position
 	 *  Z: pressure
 	 *
 	 * Absolute reportable limits:    0 - 6143.
@@ -2438,22 +2545,44 @@ proc_synaptics(struct psm_softc *sc, pac
 	    (pb->ipacket[3] & 0xc8) != 0xc0)
 		return (-1);
 
-	*x = *y = x0 = y0 = 0;
+	*x = *y = 0;
 
-	/* Pressure value. */
+	/*
+	 * Pressure value.
+	 * Interpretation:
+	 *   z = 0      No finger contact
+	 *   z = 10     Finger hovering near the pad
+	 *   z = 30     Very light finger contact
+	 *   z = 80     Normal finger contact
+	 *   z = 110    Very heavy finger contact
+	 *   z = 200    Finger lying flat on pad surface
+	 *   z = 255    Maximum reportable Z
+	 */
 	*z = pb->ipacket[2];
 
-	/* Finger width value */
+	/*
+	 * Finger width value
+	 * Interpretation:
+	 *   w = 0      Two finger on the pad (capMultiFinger needed)
+	 *   w = 1      Three or more fingers (capMultiFinger needed)
+	 *   w = 2      Pen (instead of finger) (capPen needed)
+	 *   w = 3      Reserved (passthrough?)
+	 *   w = 4-7    Finger of normal width (capPalmDetect needed)
+	 *   w = 8-14   Very wide finger or palm (capPalmDetect needed)
+	 *   w = 15     Maximum reportable width (capPalmDetect needed)
+	 */
+	/* XXX Is checking capExtended enough? */
 	if (sc->synhw.capExtended)
 		w = ((pb->ipacket[0] & 0x30) >> 2) |
 		    ((pb->ipacket[0] & 0x04) >> 1) |
 		    ((pb->ipacket[3] & 0x04) >> 2);
 	else {
-		/* Assume a finger of regular width */
+		/* Assume a finger of regular width. */
 		w = 4;
 	}
 
 	/* Handle packets from the guest device */
+	/* XXX Documentation? */
 	if (w == 3 && sc->synhw.capPassthrough) {
 		*x = ((pb->ipacket[1] & 0x10) ?
 		    pb->ipacket[4] - 256 : pb->ipacket[4]);
@@ -2470,7 +2599,7 @@ proc_synaptics(struct psm_softc *sc, pac
 			guest_buttons |= MOUSE_BUTTON3DOWN;
 
 		ms->button = touchpad_buttons | guest_buttons;
-		return (0);
+		goto SYNAPTICS_END;
 	}
 
 	/* Button presses */
@@ -2492,6 +2621,7 @@ proc_synaptics(struct psm_softc *sc, pac
 	 * the packet indicates that we have an extended
 	 * button press.
 	 */
+	/* XXX Documentation? */
 	if (pb->ipacket[3] & 0x02) {
 		/*
 		 * if directional_scrolls is not 1, we treat any of
@@ -2507,151 +2637,495 @@ proc_synaptics(struct psm_softc *sc, pac
 			if (pb->ipacket[5] & 0x02)
 				touchpad_buttons |= MOUSE_BUTTON7DOWN;
 		} else {
-			if ((pb->ipacket[4] & 0x0F) || (pb->ipacket[5] & 0x0F))
+			if ((pb->ipacket[4] & 0x0F) ||
+			    (pb->ipacket[5] & 0x0F))
 				touchpad_buttons |= MOUSE_BUTTON2DOWN;
 		}
 	}
 
 	ms->button = touchpad_buttons | guest_buttons;
 
-	/* There is a finger on the pad. */
-	if ((w >= 4 && w <= 7) && (*z >= 16 && *z < 200)) {
+	/* Check pressure to detect a real wanted action on the
+	 * touchpad. */
+	if (*z >= sc->syninfo.min_pressure) {
+		synapticsaction_t *synaction;
+		int cursor, peer, window;
+		int dx, dy, dxp, dyp;
+		int max_width, max_pressure;
+		int margin_top, margin_right, margin_bottom, margin_left;
+		int na_top, na_right, na_bottom, na_left;
+		int window_min, window_max;
+		int multiplicator;
+		int weight_current, weight_previous, weight_len_squared;
+		int div_min, div_max, div_len;
+		int vscroll_hor_area, vscroll_ver_area;
+
+		int len, weight_prev_x, weight_prev_y;
+		int div_max_x, div_max_y, div_x, div_y;
+
+		/* Read sysctl. */
+		/* XXX Verify values? */
+		max_width = sc->syninfo.max_width;
+		max_pressure = sc->syninfo.max_pressure;
+		margin_top = sc->syninfo.margin_top;
+		margin_right = sc->syninfo.margin_right;
+		margin_bottom = sc->syninfo.margin_bottom;
+		margin_left = sc->syninfo.margin_left;
+		na_top = sc->syninfo.na_top;
+		na_right = sc->syninfo.na_right;
+		na_bottom = sc->syninfo.na_bottom;
+		na_left = sc->syninfo.na_left;
+		window_min = sc->syninfo.window_min;
+		window_max = sc->syninfo.window_max;
+		multiplicator = sc->syninfo.multiplicator;
+		weight_current = sc->syninfo.weight_current;
+		weight_previous = sc->syninfo.weight_previous;
+		weight_len_squared = sc->syninfo.weight_len_squared;
+		div_min = sc->syninfo.div_min;
+		div_max = sc->syninfo.div_max;
+		div_len = sc->syninfo.div_len;
+		vscroll_hor_area = sc->syninfo.vscroll_hor_area;
+		vscroll_ver_area = sc->syninfo.vscroll_ver_area;
+
+		/* Palm detection. */
+		if (!(
+		    (sc->synhw.capMultiFinger && (w == 0 || w == 1)) ||
+		    (sc->synhw.capPalmDetect && w >= 4 && w <= max_width) ||
+		    (!sc->synhw.capPalmDetect && *z <= max_pressure) ||
+		    (sc->synhw.capPen && w == 2))) {
+			/*
+			 * We consider the packet irrelevant for the current
+			 * action when:
+			 *  - the width isn't comprised in:
+			 *    [4; max_width]
+			 *  - the pressure isn't comprised in:
+			 *    [min_pressure; max_pressure]
+			 *  - pen aren't supported but w is 2
+			 *
+			 *  Note that this doesn't terminate the current action.
+			 */
+			VLOG(2, (LOG_DEBUG,
+			    "synaptics: palm detected! (%d)\n", w));
+			goto SYNAPTICS_END;
+		}
+
+		/* Read current absolute position. */
 		x0 = ((pb->ipacket[3] & 0x10) << 8) |
-		    ((pb->ipacket[1] & 0x0f) << 8) | pb->ipacket[4];
+		    ((pb->ipacket[1] & 0x0f) << 8) |
+		    pb->ipacket[4];
 		y0 = ((pb->ipacket[3] & 0x20) << 7) |
-		    ((pb->ipacket[1] & 0xf0) << 4) | pb->ipacket[5];
+		    ((pb->ipacket[1] & 0xf0) << 4) |
+		    pb->ipacket[5];
 
-		if (sc->flags & PSM_FLAGS_FINGERDOWN) {
-			*x = x0 - sc->xold;
-			*y = y0 - sc->yold;
+		synaction = &(sc->synaction);
 
-			/*
-			 * we compute averages of x and y
-			 * movement
-			 */
-			if (sc->xaverage == 0)
-				sc->xaverage = *x;
+		/*
+		 * If the action is just beginning, init the structure and
+		 * compute tap timeout.
+		 */
+		if (!(sc->flags & PSM_FLAGS_FINGERDOWN)) {
+			VLOG(3, (LOG_DEBUG, "synaptics: ----\n"));
 
-			if (sc->yaverage == 0)
-				sc->yaverage = *y;
+			/* Store the first point of this action. */
+			synaction->start_x = x0;
+			synaction->start_y = y0;
+			dx = dy = 0;
+
+			/* Initialize queue. */
+			synaction->queue_cursor = SYNAPTICS_PACKETQUEUE;
+			synaction->queue_len = 0;
+			synaction->window_min = window_min;
+
+			/* Reset average. */
+			synaction->avg_dx = 0;
+			synaction->avg_dy = 0;
+
+			/* Reset squelch. */
+			synaction->squelch_x = 0;
+			synaction->squelch_y = 0;
+
+			/* Reset pressure peak. */
+			sc->zmax = 0;
+
+			/* Reset fingers count. */
+			synaction->fingers_nb = 0;
+
+			/* Reset virtual scrolling state. */
+			synaction->in_vscroll = 0;
+
+			/* Compute tap timeout. */
+			sc->taptimeout.tv_sec  = tap_timeout / 1000000;
+			sc->taptimeout.tv_usec = tap_timeout % 1000000;
+			timevaladd(&sc->taptimeout, &sc->lastsoftintr);
 
-			xavg = sc->xaverage;
-			yavg = sc->yaverage;
+			sc->flags |= PSM_FLAGS_FINGERDOWN;
+		} else {
+			/* Calculate the current delta. */
+			cursor = synaction->queue_cursor;
+			dx = x0 - synaction->queue[cursor].x;
+			dy = y0 - synaction->queue[cursor].y;
+		}
 
-			sc->xaverage = (xavg + *x) >> 1;
-			sc->yaverage = (yavg + *y) >> 1;
+		/* If in tap-hold, add the recorded button. */
+		if (synaction->in_taphold)
+			ms->button |= synaction->tap_button;
 
-			/*
-			 * then use the averages to compute
-			 * a sensitivity level in each dimension
-			 */
-			xsensitivity = (sc->xaverage - xavg);
-			if (xsensitivity < 0)
-				xsensitivity = -xsensitivity;
-
-			ysensitivity = (sc->yaverage - yavg);
-			if (ysensitivity < 0)
-				ysensitivity = -ysensitivity;
+		/*
+		 * From now on, we can use the SYNAPTICS_END label to skip
+		 * the current packet.
+		 */
+
+		/*
+		 * Limit the coordinates to the specified margins because
+		 * this area isn't very reliable.
+		 */
+		if (x0 <= margin_left)
+			x0 = margin_left;
+		else if (x0 >= 6143 - margin_right)
+			x0 = 6143 - margin_right;
+		if (y0 <= margin_bottom)
+			y0 = margin_bottom;
+		else if (y0 >= 6143 - margin_top)
+			y0 = 6143 - margin_top;
+
+		VLOG(3, (LOG_DEBUG, "synaptics: ipacket: [%d, %d], %d, %d\n",
+		    x0, y0, *z, w));
+
+		/* Queue this new packet. */
+		cursor = SYNAPTICS_QUEUE_CURSOR(synaction->queue_cursor - 1);
+		synaction->queue[cursor].x = x0;
+		synaction->queue[cursor].y = y0;
+		synaction->queue_cursor = cursor;
+		if (synaction->queue_len < SYNAPTICS_PACKETQUEUE)
+			synaction->queue_len++;
+		VLOG(5, (LOG_DEBUG,
+		    "synaptics: cursor[%d]: x=%d, y=%d, dx=%d, dy=%d\n",
+		    cursor, x0, y0, dx, dy));
 
+		/*
+		 * For tap, we keep the maximum number of fingers and the
+		 * pressure peak. Also with multiple fingers, we increase
+		 * the minimum window.
+		 */
+		switch (w) {
+		case 1: /* Three or more fingers. */
+			synaction->fingers_nb = imax(3, synaction->fingers_nb);
+			synaction->window_min = window_max;
+			break;
+		case 0: /* Two fingers. */
+			synaction->fingers_nb = imax(2, synaction->fingers_nb);
+			synaction->window_min = window_max;
+			break;
+		default: /* One finger or undetectable. */
+			synaction->fingers_nb = imax(1, synaction->fingers_nb);
+		}
+		sc->zmax = imax(*z, sc->zmax);
+
+		/* Do we have enough packets to consider this a movement? */
+		if (synaction->queue_len < synaction->window_min)
+			goto SYNAPTICS_END;
+
+		/* Is a scrolling action occuring? */
+		if (!synaction->in_taphold && !synaction->in_vscroll) {
 			/*
-			 * The sensitivity level is higher the faster
-			 * the finger is moving.  It also tends to be
-			 * higher in the middle of a touchpad motion
-			 * than on either end
-			 * Note - sensitivity gets to 0 when moving slowly -
-			 * so we add 1 to it to give it a meaningful value
-			 * in that case.
+			 * A scrolling action must not conflict with a tap
+			 * action. Here are the conditions to consider a
+			 * scrolling action:
+			 *  - the action in a configurable area
+			 *  - one of the following:
+			 *     . the distance between the last packet and the
+			 *       first should be above a configurable minimum
+			 *     . tap timed out
 			 */
-			sensitivity = (xsensitivity & ysensitivity) + 1;
+			dxp = abs(synaction->queue[synaction->queue_cursor].x -
+			    synaction->start_x);
+			dyp = abs(synaction->queue[synaction->queue_cursor].y -
+			    synaction->start_y);
+
+			if (timevalcmp(&sc->lastsoftintr, &sc->taptimeout, >) ||
+			    dxp >= sc->syninfo.vscroll_min_delta ||
+			    dyp >= sc->syninfo.vscroll_min_delta) {
+				/* Check for horizontal scrolling. */
+				if ((vscroll_hor_area > 0 &&
+				    synaction->start_y <= vscroll_hor_area) ||
+				    (vscroll_hor_area < 0 &&
+				     synaction->start_y >=
+				     6143 + vscroll_hor_area))
+					synaction->in_vscroll += 2;
+
+				/* Check for vertical scrolling. */
+				if ((vscroll_ver_area > 0 &&
+				    synaction->start_x <= vscroll_ver_area) ||
+				    (vscroll_ver_area < 0 &&
+				     synaction->start_x >=
+				     6143 + vscroll_ver_area))
+					synaction->in_vscroll += 1;
+
+				/* Avoid conflicts if area overlaps. */
+				if (synaction->in_vscroll == 3)
+					synaction->in_vscroll =
+					    (dxp > dyp) ? 2 : 1;
+			}
+			VLOG(5, (LOG_DEBUG,
+			    "synaptics: virtual scrolling: %s "
+			    "(direction=%d, dxp=%d, dyp=%d)\n",
+			    synaction->in_vscroll ? "YES" : "NO",
+			    synaction->in_vscroll, dxp, dyp));
+		}
 
+		weight_prev_x = weight_prev_y = weight_previous;
+		div_max_x = div_max_y = div_max;
+
+		if (synaction->in_vscroll) {
+			/* Dividers are different with virtual scrolling. */
+			div_min = sc->syninfo.vscroll_div_min;
+			div_max_x = div_max_y = sc->syninfo.vscroll_div_max;
+		} else {
 			/*
-			 * If either our x or y change is greater than
-			 * our hi/low speed threshold - we do the high-speed
-			 * absolute to relative calculation otherwise
-			 * we do the low-speed calculation.
+			 * There's a lot of noise in coordinates when
+			 * the finger is on the touchpad's borders. When
+			 * using this area, we apply a special weight and
+			 * div.
 			 */
-			if ((*x > sc->syninfo.low_speed_threshold ||
-			    *x < -sc->syninfo.low_speed_threshold) ||
-			    (*y > sc->syninfo.low_speed_threshold ||
-			    *y < -sc->syninfo.low_speed_threshold)) {
-				x0 = (x0 + sc->xold * 3) / 4;
-				y0 = (y0 + sc->yold * 3) / 4;
-				*x = (x0 - sc->xold) * 10 / 85;
-				*y = (y0 - sc->yold) * 10 / 85;
-			} else {
-				/*
-				 * This is the low speed calculation.
-				 * We simply check to see if our movement is
-				 * more than our minimum movement threshold
-				 * and if it is - set the movement to 1
-				 * in the correct direction.
-				 * NOTE - Normally this would result
-				 * in pointer movement that was WAY too fast.
-				 * This works due to the movement squelch
-				 * we do later.
-				 */
-				if (*x < -sc->syninfo.min_movement)
-					*x = -1;
-				else if (*x > sc->syninfo.min_movement)
-					*x = 1;
-				else
-					*x = 0;
-				if (*y < -sc->syninfo.min_movement)
-					*y = -1;
-				else if (*y > sc->syninfo.min_movement)
-					*y = 1;
-				else
-					*y = 0;
+			if (x0 <= na_left || x0 >= 6143 - na_right) {
+				weight_prev_x = sc->syninfo.weight_previous_na;
+				div_max_x = sc->syninfo.div_max_na;
+			}
 
+			if (y0 <= na_bottom || y0 >= 6143 - na_top) {
+				weight_prev_y = sc->syninfo.weight_previous_na;
+				div_max_y = sc->syninfo.div_max_na;
 			}
-		} else
-			sc->flags |= PSM_FLAGS_FINGERDOWN;
+		}
 
 		/*
-		 * The squelch process.  Take our sensitivity value and
-		 * add it to the current squelch value - if squelch is
-		 * less than our squelch threshold we kill the movement,
-		 * otherwise we reset squelch and pass the movement through.
-		 * Since squelch is cumulative - when mouse movement is slow
-		 * (around sensitivity 1) the net result is that only 1
-		 * out of every squelch_level packets is delivered,
-		 * effectively slowing down the movement.
-		 */
-		sc->squelch += sensitivity;
-		if (sc->squelch < sc->syninfo.squelch_level) {
-			*x = 0;
-			*y = 0;
-		} else
-			sc->squelch = 0;
+		 * Calculate weights for the average operands and
+		 * the divisor. Both depend on the distance between
+		 * the current packet and a previous one (based on the
+		 * window width).
+		 */
+		window = imin(synaction->queue_len, window_max);
+		peer = SYNAPTICS_QUEUE_CURSOR(cursor + window - 1);
+		dxp = abs(x0 - synaction->queue[peer].x) + 1;
+		dyp = abs(y0 - synaction->queue[peer].y) + 1;
+		len = (dxp * dxp) + (dyp * dyp);
+		weight_prev_x = imin(weight_prev_x,
+		    weight_len_squared * weight_prev_x / len);
+		weight_prev_y = imin(weight_prev_y,
+		    weight_len_squared * weight_prev_y / len);
+
+		len = (dxp + dyp) / 2;
+		div_x = div_len * div_max_x / len;
+		div_x = imin(div_max_x, div_x);
+		div_x = imax(div_min, div_x);
+		div_y = div_len * div_max_y / len;
+		div_y = imin(div_max_y, div_y);
+		div_y = imax(div_min, div_y);
+
+		VLOG(3, (LOG_DEBUG,
+		    "synaptics: peer=%d, len=%d, weight=%d/%d, div=%d/%d\n",
+		    peer, len, weight_prev_x, weight_prev_y, div_x, div_y));
+
+		/* Compute averages. */
+		synaction->avg_dx =
+		    (weight_current * dx * multiplicator +
+		     weight_prev_x * synaction->avg_dx) /
+		    (weight_current + weight_prev_x);
+
+		synaction->avg_dy =
+		    (weight_current * dy * multiplicator +
+		     weight_prev_y * synaction->avg_dy) /
+		    (weight_current + weight_prev_y);
+
+		VLOG(5, (LOG_DEBUG,
+		    "synaptics: avg_dx~=%d, avg_dy~=%d\n",
+		    synaction->avg_dx / multiplicator,
+		    synaction->avg_dy / multiplicator));
+
+		/* Use these averages to calculate x & y. */
+		synaction->squelch_x += synaction->avg_dx;
+		*x = synaction->squelch_x / (div_x * multiplicator);
+		synaction->squelch_x = synaction->squelch_x %
+		    (div_x * multiplicator);
+
+		synaction->squelch_y += synaction->avg_dy;
+		*y = synaction->squelch_y / (div_y * multiplicator);
+		synaction->squelch_y = synaction->squelch_y %
+		    (div_y * multiplicator);
+
+		if (synaction->in_vscroll) {
+			switch(synaction->in_vscroll) {
+			case 1: /* Vertical scrolling. */
+				if (*y != 0)
+					ms->button |= (*y > 0) ?
+					    MOUSE_BUTTON4DOWN :
+					    MOUSE_BUTTON5DOWN;
+				break;
+			case 2: /* Horizontal scrolling. */
+				if (*x != 0)
+					ms->button |= (*x > 0) ?
+					    MOUSE_BUTTON7DOWN :
+					    MOUSE_BUTTON6DOWN;
+				break;
+			}
+
+			/* The pointer is not moved. */
+			*x = *y = 0;
+		} else {
+			VLOG(3, (LOG_DEBUG, "synaptics: [%d, %d] -> [%d, %d]\n",
+			    dx, dy, *x, *y));
+		}
+	} else if (sc->flags & PSM_FLAGS_FINGERDOWN) {
+		/*
+		 * An action is currently taking place but the pressure
+		 * dropped under the minimum, putting an end to it.
+		 */
+		synapticsaction_t *synaction;
+		int taphold_timeout, dx, dy, tap_max_delta;
+
+		synaction = &(sc->synaction);
+		dx = abs(synaction->queue[synaction->queue_cursor].x -
+		    synaction->start_x);
+		dy = abs(synaction->queue[synaction->queue_cursor].y -
+		    synaction->start_y);
+
+		/* Max delta is disabled for multi-fingers tap. */
+		if (synaction->fingers_nb > 1)
+			tap_max_delta = imax(dx, dy);
+		else
+			tap_max_delta = sc->syninfo.tap_max_delta;
 
-		sc->xold = x0;
-		sc->yold = y0;
-		sc->zmax = imax(*z, sc->zmax);
-	} else {
 		sc->flags &= ~PSM_FLAGS_FINGERDOWN;
 
-		if (sc->zmax > tap_threshold &&
-		    timevalcmp(&sc->lastsoftintr, &sc->taptimeout, <=)) {
-			if (w == 0)
-				ms->button |= MOUSE_BUTTON3DOWN;
-			else if (w == 1)
-				ms->button |= MOUSE_BUTTON2DOWN;
-			else
-				ms->button |= MOUSE_BUTTON1DOWN;
-		}
+		/* Check for tap. */
+		VLOG(3, (LOG_DEBUG,
+		    "synaptics: zmax=%d, dx=%d, dy=%d, "
+		    "delta=%d, fingers=%d, queue=%d\n",
+		    sc->zmax, dx, dy, tap_max_delta, synaction->fingers_nb,
+		    synaction->queue_len));
+		if (!synaction->in_vscroll && sc->zmax >= tap_threshold &&
+		    timevalcmp(&sc->lastsoftintr, &sc->taptimeout, <=) &&
+		    dx <= tap_max_delta && dy <= tap_max_delta &&
+		    synaction->queue_len >= sc->syninfo.tap_min_queue) {
+			/*
+			 * We have a tap if:
+			 *   - the maximum pressure went over tap_threshold
+			 *   - the action ended before tap_timeout
+			 *
+			 * To handle tap-hold, we must delay any button push to
+			 * the next action.
+			 */
+			if (synaction->in_taphold) {
+				/*
+				 * This is the second and last tap of a
+				 * double tap action, not a tap-hold.
+				 */
+				synaction->in_taphold = 0;
 
-		sc->zmax = 0;
-		sc->taptimeout.tv_sec = tap_timeout / 1000000;
-		sc->taptimeout.tv_usec = tap_timeout % 1000000;
-		timevaladd(&sc->taptimeout, &sc->lastsoftintr);
+				/*
+				 * For double-tap to work:
+				 *   - no button press is emitted (to
+				 *     simulate a button release)
+				 *   - PSM_FLAGS_FINGERDOWN is set to
+				 *     force the next packet to emit a
+				 *     button press)
+				 */
+				VLOG(2, (LOG_DEBUG,
+				    "synaptics: button RELEASE: %d\n",
+				    synaction->tap_button));
+				sc->flags |= PSM_FLAGS_FINGERDOWN;
+			} else {
+				/*
+				 * This is the first tap: we set the
+				 * tap-hold state and notify the button
+				 * down event.
+				 */
+				synaction->in_taphold = 1;
+				taphold_timeout = sc->syninfo.taphold_timeout;
+				sc->taptimeout.tv_sec  = taphold_timeout /
+				    1000000;
+				sc->taptimeout.tv_usec = taphold_timeout %
+				    1000000;
+				timevaladd(&sc->taptimeout, &sc->lastsoftintr);
+
+				switch (synaction->fingers_nb) {
+				case 3:
+					synaction->tap_button =
+					    MOUSE_BUTTON2DOWN;
+					break;
+				case 2:
+					synaction->tap_button =
+					    MOUSE_BUTTON3DOWN;
+					break;
+				default:
+					synaction->tap_button =
+					    MOUSE_BUTTON1DOWN;
+				}
+				VLOG(2, (LOG_DEBUG,
+				    "synaptics: button PRESS: %d\n",
+				    synaction->tap_button));
+				ms->button |= synaction->tap_button;
+			}
+		} else {
+			/*
+			 * Not enough pressure or timeout: reset
+			 * tap-hold state.
+			 */
+			if (synaction->in_taphold) {
+				VLOG(2, (LOG_DEBUG,
+				    "synaptics: button RELEASE: %d\n",
+				    synaction->tap_button));
+				synaction->in_taphold = 0;
+			} else {
+				VLOG(2, (LOG_DEBUG,
+				    "synaptics: not a tap-hold\n"));
+			}
+		}
+	} else if (!(sc->flags & PSM_FLAGS_FINGERDOWN) &&
+	    sc->synaction.in_taphold) {
+		/*
+		 * For a tap-hold to work, the button must remain down at
+		 * least until timeout (where the in_taphold flags will be
+		 * cleared) or during the next action.
+		 */
+		if (timevalcmp(&sc->lastsoftintr, &sc->taptimeout, <=)) {
+			ms->button |= sc->synaction.tap_button;
+		} else {
+			VLOG(2, (LOG_DEBUG,
+			    "synaptics: button RELEASE: %d\n",
+			    sc->synaction.tap_button));
+			sc->synaction.in_taphold = 0;
+		}
 	}
 
-	/* Use the extra buttons as a scrollwheel */
-	if (ms->button & MOUSE_BUTTON4DOWN)
+SYNAPTICS_END:
+	/*
+	 * Use the extra buttons as a scrollwheel
+	 *
+	 * XXX X.Org uses the Z axis for vertical wheel only,
+	 * whereas moused(8) understands special values to differ
+	 * vertical and horizontal wheels.
+	 *
+	 * xf86-input-mouse needs therefore a small patch to
+	 * understand these special values. Without it, the
+	 * horizontal wheel acts as a vertical wheel in X.Org.
+	 *
+	 * That's why the horizontal wheel is disabled by
+	 * default for now.
+	 */
+	if (ms->button & MOUSE_BUTTON4DOWN) {
 		*z = -1;
-	else if (ms->button & MOUSE_BUTTON5DOWN)
+		ms->button &= ~MOUSE_BUTTON4DOWN;
+	} else if (ms->button & MOUSE_BUTTON5DOWN) {
 		*z = 1;
-	else
+		ms->button &= ~MOUSE_BUTTON5DOWN;
+	} else if (ms->button & MOUSE_BUTTON6DOWN) {
+		*z = -2;
+		ms->button &= ~MOUSE_BUTTON6DOWN;
+	} else if (ms->button & MOUSE_BUTTON7DOWN) {
+		*z = 2;
+		ms->button &= ~MOUSE_BUTTON7DOWN;
+	} else
 		*z = 0;
 
 	return (0);
@@ -3400,13 +3874,87 @@ enable_4dplus(struct psm_softc *sc)
 
 /* Synaptics Touchpad */
 static int
-enable_synaptics(struct psm_softc *sc)
+synaptics_sysctl(SYSCTL_HANDLER_ARGS)
 {
-	int status[3];
-	KBDC kbdc;
+	int error, arg;
 
-	if (!synaptics_support)
-		return (FALSE);
+	/* Read the current value. */
+	arg = *(int *)oidp->oid_arg1;
+	error = sysctl_handle_int(oidp, &arg, 0, req);
+
+	/* Sanity check. */
+	if (error || !req->newptr)
+		return (error);
+
+	/*
+	 * Check that the new value is in the concerned node's range
+	 * of values.
+	 */
+	switch (oidp->oid_arg2) {
+	case SYNAPTICS_SYSCTL_MIN_PRESSURE:
+	case SYNAPTICS_SYSCTL_MAX_PRESSURE:
+		if (arg < 0 || arg > 255)
+			return (EINVAL);
+		break;
+	case SYNAPTICS_SYSCTL_MAX_WIDTH:
+		if (arg < 4 || arg > 15)
+			return (EINVAL);
+		break;
+	case SYNAPTICS_SYSCTL_MARGIN_TOP:
+	case SYNAPTICS_SYSCTL_MARGIN_RIGHT:
+	case SYNAPTICS_SYSCTL_MARGIN_BOTTOM:
+	case SYNAPTICS_SYSCTL_MARGIN_LEFT:
+	case SYNAPTICS_SYSCTL_NA_TOP:
+	case SYNAPTICS_SYSCTL_NA_RIGHT:
+	case SYNAPTICS_SYSCTL_NA_BOTTOM:
+	case SYNAPTICS_SYSCTL_NA_LEFT:
+		if (arg < 0 || arg > 6143)
+			return (EINVAL);
+		break;
+	case SYNAPTICS_SYSCTL_WINDOW_MIN:
+	case SYNAPTICS_SYSCTL_WINDOW_MAX:
+	case SYNAPTICS_SYSCTL_TAP_MIN_QUEUE:
+		if (arg < 1 || arg > SYNAPTICS_PACKETQUEUE)
+			return (EINVAL);
+		break;
+	case SYNAPTICS_SYSCTL_MULTIPLICATOR:
+	case SYNAPTICS_SYSCTL_WEIGHT_CURRENT:
+	case SYNAPTICS_SYSCTL_WEIGHT_PREVIOUS:
+	case SYNAPTICS_SYSCTL_WEIGHT_PREVIOUS_NA:
+	case SYNAPTICS_SYSCTL_WEIGHT_LEN_SQUARED:
+	case SYNAPTICS_SYSCTL_DIV_MIN:
+	case SYNAPTICS_SYSCTL_DIV_MAX:
+	case SYNAPTICS_SYSCTL_DIV_MAX_NA:
+	case SYNAPTICS_SYSCTL_DIV_LEN:
+	case SYNAPTICS_SYSCTL_VSCROLL_DIV_MIN:
+	case SYNAPTICS_SYSCTL_VSCROLL_DIV_MAX:
+		if (arg < 1)
+			return (EINVAL);
+		break;
+	case SYNAPTICS_SYSCTL_TAP_MAX_DELTA:
+	case SYNAPTICS_SYSCTL_TAPHOLD_TIMEOUT:
+	case SYNAPTICS_SYSCTL_VSCROLL_MIN_DELTA:
+		if (arg < 0)
+			return (EINVAL);
+		break;
+	case SYNAPTICS_SYSCTL_VSCROLL_HOR_AREA:
+	case SYNAPTICS_SYSCTL_VSCROLL_VER_AREA:
+		if (arg < -6143 || arg > 6143)
+			return (EINVAL);
+		break;
+	default:
+		return (EINVAL);
+	}
+
+	/* Update. */
+	*(int *)oidp->oid_arg1 = arg;
+
+	return (error);
+}
+
+static void
+synaptics_sysctl_create_tree(struct psm_softc *sc)
+{
 
 	/* Attach extra synaptics sysctl nodes under hw.psm.synaptics */
 	sysctl_ctx_init(&sc->syninfo.sysctl_ctx);
@@ -3414,54 +3962,307 @@ enable_synaptics(struct psm_softc *sc)
 	    SYSCTL_STATIC_CHILDREN(_hw_psm), OID_AUTO, "synaptics", CTLFLAG_RD,
 	    0, "Synaptics TouchPad");
 
-	/*
-	 * synaptics_directional_scrolls - if non-zero, the directional
-	 * pad scrolls, otherwise it registers as a middle-click.
-	 */
+	/* hw.psm.synaptics.directional_scrolls. */
 	sc->syninfo.directional_scrolls = 1;
 	SYSCTL_ADD_INT(&sc->syninfo.sysctl_ctx,
 	    SYSCTL_CHILDREN(sc->syninfo.sysctl_tree), OID_AUTO,
-	    "directional_scrolls", CTLFLAG_RW,
+	    "directional_scrolls", CTLFLAG_RW|CTLFLAG_ANYBODY,
 	    &sc->syninfo.directional_scrolls, 0,
-	    "directional pad scrolls (1=yes  0=3rd button)");
+	    "Enable hardware scrolling pad (if non-zero) or register it as "
+	    "a middle-click (if 0)");
 
-	/*
-	 * Synaptics_low_speed_threshold - the number of touchpad units
-	 * below-which we go into low-speed tracking mode.
-	 */
-	sc->syninfo.low_speed_threshold = 20;
-	SYSCTL_ADD_INT(&sc->syninfo.sysctl_ctx,
+	/* hw.psm.synaptics.min_pressure. */
+	sc->syninfo.min_pressure = 16;
+	SYSCTL_ADD_PROC(&sc->syninfo.sysctl_ctx,
 	    SYSCTL_CHILDREN(sc->syninfo.sysctl_tree), OID_AUTO,
-	    "low_speed_threshold", CTLFLAG_RW,
-	    &sc->syninfo.low_speed_threshold, 0,
-	    "threshold between low and hi speed positioning");
-
-	/*
-	 * Synaptics_min_movement - the number of touchpad units below
-	 * which we ignore altogether.
-	 */
-	sc->syninfo.min_movement = 2;
-	SYSCTL_ADD_INT(&sc->syninfo.sysctl_ctx,
+	    "min_pressure", CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY,
+	    &sc->syninfo.min_pressure, SYNAPTICS_SYSCTL_MIN_PRESSURE,
+	    synaptics_sysctl, "I",
+	    "Minimum pressure required to start an action");
+
+	/* hw.psm.synaptics.max_pressure. */

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
From maxim at FreeBSD.org  Tue Oct 14 17:53:27 2008
From: maxim at FreeBSD.org (Maxim Konovalov)
Date: Tue Oct 14 17:53:38 2008
Subject: svn commit: r183889 - head/sbin/ipfw
Message-ID: <200810141753.m9EHrQUF012474@svn.freebsd.org>

Author: maxim
Date: Tue Oct 14 17:53:26 2008
New Revision: 183889
URL: http://svn.freebsd.org/changeset/base/183889

Log:
  o Do nothing in show_nat() for a test mode (-n).  This prevents
  show_nat() from endless loop and makes work ipfw -n nat <...>.
  
  PR:		bin/128064
  Submitted by:	sem
  MFC after:	1 month

Modified:
  head/sbin/ipfw/ipfw2.c

Modified: head/sbin/ipfw/ipfw2.c
==============================================================================
--- head/sbin/ipfw/ipfw2.c	Tue Oct 14 17:48:36 2008	(r183888)
+++ head/sbin/ipfw/ipfw2.c	Tue Oct 14 17:53:26 2008	(r183889)
@@ -3856,9 +3856,6 @@ nospace:
 }
 
 static void
-show_nat(int ac, char **av);
-
-static void
 print_nat_config(char *buf) {
 	struct cfg_nat *n;
 	int i, cnt, flag, off;
@@ -4066,11 +4063,6 @@ config_nat(int ac, char **av)
 	i = do_cmd(IP_FW_NAT_CFG, buf, off);
 	if (i)
 		err(1, "setsockopt(%s)", "IP_FW_NAT_CFG");
-
-	/* After every modification, we show the resultant rule. */
-	int _ac = 3;
-	char *_av[] = {"show", "config", id};
-	show_nat(_ac, _av);
 }
 
 static void
@@ -6035,6 +6027,9 @@ show_nat(int ac, char **av)
 	lrule = IPFW_DEFAULT_RULE; /* max ipfw rule number */
 	ac--; av++;
 
+	if (test_only)
+		return;
+
 	/* Parse parameters. */
 	for (cmd = IP_FW_NAT_GET_LOG, do_cfg = 0; ac != 0; ac--, av++) {
 		if (!strncmp(av[0], "config", strlen(av[0]))) {
@@ -6059,6 +6054,7 @@ show_nat(int ac, char **av)
 		if (do_cmd(cmd, data, (uintptr_t)&nbytes) < 0)
 			err(EX_OSERR, "getsockopt(IP_FW_GET_%s)",
 			    (cmd == IP_FW_NAT_GET_LOG) ? "LOG" : "CONFIG");
+		printf("nbytes %b\n", nbytes);
 	}
 	if (nbytes == 0)
 		exit(0);
From maxim at FreeBSD.org  Tue Oct 14 17:59:40 2008
From: maxim at FreeBSD.org (Maxim Konovalov)
Date: Tue Oct 14 17:59:45 2008
Subject: svn commit: r183890 - head/sbin/ipfw
Message-ID: <200810141759.m9EHxdhc012624@svn.freebsd.org>

Author: maxim
Date: Tue Oct 14 17:59:39 2008
New Revision: 183890
URL: http://svn.freebsd.org/changeset/base/183890

Log:
  o Remove a debug code and restore an accidentally deleted code
  in a previous commit.

Modified:
  head/sbin/ipfw/ipfw2.c

Modified: head/sbin/ipfw/ipfw2.c
==============================================================================
--- head/sbin/ipfw/ipfw2.c	Tue Oct 14 17:53:26 2008	(r183889)
+++ head/sbin/ipfw/ipfw2.c	Tue Oct 14 17:59:39 2008	(r183890)
@@ -3856,6 +3856,9 @@ nospace:
 }
 
 static void
+show_nat(int ac, char **av);
+
+static void
 print_nat_config(char *buf) {
 	struct cfg_nat *n;
 	int i, cnt, flag, off;
@@ -4063,6 +4066,11 @@ config_nat(int ac, char **av)
 	i = do_cmd(IP_FW_NAT_CFG, buf, off);
 	if (i)
 		err(1, "setsockopt(%s)", "IP_FW_NAT_CFG");
+
+	/* After every modification, we show the resultant rule. */
+	int _ac = 3;
+	char *_av[] = {"show", "config", id};
+	show_nat(_ac, _av);
 }
 
 static void
@@ -6054,7 +6062,6 @@ show_nat(int ac, char **av)
 		if (do_cmd(cmd, data, (uintptr_t)&nbytes) < 0)
 			err(EX_OSERR, "getsockopt(IP_FW_GET_%s)",
 			    (cmd == IP_FW_NAT_GET_LOG) ? "LOG" : "CONFIG");
-		printf("nbytes %b\n", nbytes);
 	}
 	if (nbytes == 0)
 		exit(0);
From thompsa at FreeBSD.org  Tue Oct 14 18:24:40 2008
From: thompsa at FreeBSD.org (Andrew Thompson)
Date: Tue Oct 14 18:24:46 2008
Subject: svn commit: r183891 - head/sys/dev/usb
Message-ID: <200810141824.m9EIOeh5013104@svn.freebsd.org>

Author: thompsa
Date: Tue Oct 14 18:24:40 2008
New Revision: 183891
URL: http://svn.freebsd.org/changeset/base/183891

Log:
  Remove the 'old' Novatel MC950D entry which was slightly incorrect, NetBSD has
  already picked up the new name so run with it.

Modified:
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/usbdevs
==============================================================================
--- head/sys/dev/usb/usbdevs	Tue Oct 14 17:59:39 2008	(r183890)
+++ head/sys/dev/usb/usbdevs	Tue Oct 14 18:24:40 2008	(r183891)
@@ -1839,7 +1839,6 @@ product NOVATEL X950D		0x1450	Merlin X95
 product NOVATEL ES620		0x2100	ES620 CDMA
 product NOVATEL U720		0x2110	Merlin U720
 product NOVATEL U727		0x4100	Merlin U727 CDMA
-product NOVATEL U950D		0x4400	Novatel MC950D HSUPA
 product NOVATEL MC950D		0x4400	Novatel MC950D HSUPA
 product NOVATEL ZEROCD		0x5010	Novatel ZeroCD
 product NOVATEL2 FLEXPACKGPS	0x0100	NovAtel FlexPack GPS receiver
From mav at FreeBSD.org  Tue Oct 14 19:58:26 2008
From: mav at FreeBSD.org (Alexander Motin)
Date: Tue Oct 14 19:58:38 2008
Subject: svn commit: r183894 - head/sys/dev/sound/pci/hda
Message-ID: <200810141958.m9EJwQqF014891@svn.freebsd.org>

Author: mav
Date: Tue Oct 14 19:58:26 2008
New Revision: 183894
URL: http://svn.freebsd.org/changeset/base/183894

Log:
  Add all Sigmatel/IDT codecs I could find.
  Add IDT and Intel unknown codecs.
  
  PR:		kern/125822

Modified:
  head/sys/dev/sound/pci/hda/hdac.c

Modified: head/sys/dev/sound/pci/hda/hdac.c
==============================================================================
--- head/sys/dev/sound/pci/hda/hdac.c	Tue Oct 14 19:48:58 2008	(r183893)
+++ head/sys/dev/sound/pci/hda/hdac.c	Tue Oct 14 19:58:26 2008	(r183894)
@@ -579,15 +579,55 @@ static const struct {
 #define HDA_CODEC_STAC9228D	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7617)
 #define HDA_CODEC_STAC9227X	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7618)
 #define HDA_CODEC_STAC9227D	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7619)
+#define HDA_CODEC_STAC9274	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7620)
+#define HDA_CODEC_STAC9274D	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7621)
+#define HDA_CODEC_STAC9273X	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7622)
+#define HDA_CODEC_STAC9273D	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7623)
+#define HDA_CODEC_STAC9272X	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7624)
+#define HDA_CODEC_STAC9272D	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7625)
+#define HDA_CODEC_STAC9271X	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7626)
 #define HDA_CODEC_STAC9271D	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7627)
+#define HDA_CODEC_STAC9274X5NH	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7628)
+#define HDA_CODEC_STAC9274D5NH	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7629)
+#define HDA_CODEC_STAC9250	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7634)
+#define HDA_CODEC_STAC9251	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7636)
+#define HDA_CODEC_IDT92HD700X	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7638)
+#define HDA_CODEC_IDT92HD700D	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7639)
+#define HDA_CODEC_IDT92HD206X	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7645)
+#define HDA_CODEC_IDT92HD206D	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7646)
 #define HDA_CODEC_STAC9872AK	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7662)
 #define HDA_CODEC_STAC9221	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7680)
 #define HDA_CODEC_STAC922XD	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7681)
+#define HDA_CODEC_STAC9221_A2	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7682)
 #define HDA_CODEC_STAC9221D	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7683)
 #define HDA_CODEC_STAC9220	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7690)
-#define HDA_CODEC_STAC9205	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x76a0)
+#define HDA_CODEC_STAC9200D	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7691)
+#define HDA_CODEC_IDT92HD005	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7698)
+#define HDA_CODEC_IDT92HD005D	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7699)
+#define HDA_CODEC_STAC9205X	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x76a0)
+#define HDA_CODEC_STAC9205D	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x76a1)
+#define HDA_CODEC_STAC9204X	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x76a2)
+#define HDA_CODEC_STAC9204D	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x76a3)
+#define HDA_CODEC_STAC9220_A2	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7880)
+#define HDA_CODEC_STAC9220_A1	HDA_CODEC_CONSTRUCT(SIGMATEL, 0x7882)
 #define HDA_CODEC_STACXXXX	HDA_CODEC_CONSTRUCT(SIGMATEL, 0xffff)
 
+/* IDT */
+#define IDT_VENDORID		0x111d
+#define HDA_CODEC_IDT92HD75BX	HDA_CODEC_CONSTRUCT(IDT, 0x7603)
+#define HDA_CODEC_IDT92HD83C1X	HDA_CODEC_CONSTRUCT(IDT, 0x7604)
+#define HDA_CODEC_IDT92HD81B1X	HDA_CODEC_CONSTRUCT(IDT, 0x7605)
+#define HDA_CODEC_IDT92HD75B3	HDA_CODEC_CONSTRUCT(IDT, 0x7608)
+#define HDA_CODEC_IDT92HD73D1	HDA_CODEC_CONSTRUCT(IDT, 0x7674)
+#define HDA_CODEC_IDT92HD73C1	HDA_CODEC_CONSTRUCT(IDT, 0x7675)
+#define HDA_CODEC_IDT92HD73E1	HDA_CODEC_CONSTRUCT(IDT, 0x7676)
+#define HDA_CODEC_IDT92HD71B8	HDA_CODEC_CONSTRUCT(IDT, 0x76b0)
+#define HDA_CODEC_IDT92HD71B7	HDA_CODEC_CONSTRUCT(IDT, 0x76b2)
+#define HDA_CODEC_IDT92HD71B5	HDA_CODEC_CONSTRUCT(IDT, 0x76b6)
+#define HDA_CODEC_IDT92HD83C1C	HDA_CODEC_CONSTRUCT(IDT, 0x76d4)
+#define HDA_CODEC_IDT92HD81B1C	HDA_CODEC_CONSTRUCT(IDT, 0x76d5)
+#define HDA_CODEC_IDTXXXX	HDA_CODEC_CONSTRUCT(IDT, 0xffff)
+
 /* Silicon Image */
 #define SII_VENDORID	0x1095
 #define HDA_CODEC_SIIXXXX	HDA_CODEC_CONSTRUCT(SII, 0xffff)
@@ -632,6 +672,9 @@ static const struct {
 /* NVIDIA */
 #define HDA_CODEC_NVIDIAXXXX	HDA_CODEC_CONSTRUCT(NVIDIA, 0xffff)
 
+/* INTEL */
+#define HDA_CODEC_INTELXXXX	HDA_CODEC_CONSTRUCT(INTEL, 0xffff)
+
 /* Codecs */
 static const struct {
 	uint32_t id;
@@ -661,21 +704,57 @@ static const struct {
 	{ HDA_CODEC_AD1988,    "Analog Devices AD1988" },
 	{ HDA_CODEC_AD1988B,   "Analog Devices AD1988B" },
 	{ HDA_CODEC_CMI9880,   "CMedia CMI9880" },
+	{ HDA_CODEC_STAC9200D, "Sigmatel STAC9200D" },
+	{ HDA_CODEC_STAC9204X, "Sigmatel STAC9204X" },
+	{ HDA_CODEC_STAC9204D, "Sigmatel STAC9204D" },
+	{ HDA_CODEC_STAC9205X, "Sigmatel STAC9205X" },
+	{ HDA_CODEC_STAC9205D, "Sigmatel STAC9205D" },
+	{ HDA_CODEC_STAC9220,  "Sigmatel STAC9220" },
+	{ HDA_CODEC_STAC9220_A1, "Sigmatel STAC9220_A1" },
+	{ HDA_CODEC_STAC9220_A2, "Sigmatel STAC9220_A2" },
 	{ HDA_CODEC_STAC9221,  "Sigmatel STAC9221" },
+	{ HDA_CODEC_STAC9221_A2, "Sigmatel STAC9221_A2" },
 	{ HDA_CODEC_STAC9221D, "Sigmatel STAC9221D" },
-	{ HDA_CODEC_STAC9220,  "Sigmatel STAC9220" },
 	{ HDA_CODEC_STAC922XD, "Sigmatel STAC9220D/9223D" },
-	{ HDA_CODEC_STAC9230X, "Sigmatel STAC9230X" },
-	{ HDA_CODEC_STAC9230D, "Sigmatel STAC9230D" },
-	{ HDA_CODEC_STAC9229X, "Sigmatel STAC9229X" },
-	{ HDA_CODEC_STAC9229D, "Sigmatel STAC9229D" },
-	{ HDA_CODEC_STAC9228X, "Sigmatel STAC9228X" },
-	{ HDA_CODEC_STAC9228D, "Sigmatel STAC9228D" },
 	{ HDA_CODEC_STAC9227X, "Sigmatel STAC9227X" },
 	{ HDA_CODEC_STAC9227D, "Sigmatel STAC9227D" },
+	{ HDA_CODEC_STAC9228X, "Sigmatel STAC9228X" },
+	{ HDA_CODEC_STAC9228D, "Sigmatel STAC9228D" },
+	{ HDA_CODEC_STAC9229X, "Sigmatel STAC9229X" },
+	{ HDA_CODEC_STAC9229D, "Sigmatel STAC9229D" },
+	{ HDA_CODEC_STAC9230X, "Sigmatel STAC9230X" },
+	{ HDA_CODEC_STAC9230D, "Sigmatel STAC9230D" },
+	{ HDA_CODEC_STAC9250,  "Sigmatel STAC9250" },
+	{ HDA_CODEC_STAC9251,  "Sigmatel STAC9251" },
+	{ HDA_CODEC_STAC9271X, "Sigmatel STAC9271X" },
 	{ HDA_CODEC_STAC9271D, "Sigmatel STAC9271D" },
-	{ HDA_CODEC_STAC9205,  "Sigmatel STAC9205" },
-	{ HDA_CODEC_STAC9872AK,"Sigmatel STAC9872AK" },
+	{ HDA_CODEC_STAC9272X, "Sigmatel STAC9272X" },
+	{ HDA_CODEC_STAC9272D, "Sigmatel STAC9272D" },
+	{ HDA_CODEC_STAC9273X, "Sigmatel STAC9273X" },
+	{ HDA_CODEC_STAC9273D, "Sigmatel STAC9273D" },
+	{ HDA_CODEC_STAC9274,  "Sigmatel STAC9274" },
+	{ HDA_CODEC_STAC9274D, "Sigmatel STAC9274D" },
+	{ HDA_CODEC_STAC9274X5NH, "Sigmatel STAC9274X5NH" },
+	{ HDA_CODEC_STAC9274D5NH, "Sigmatel STAC9274D5NH" },
+	{ HDA_CODEC_STAC9872AK, "Sigmatel STAC9872AK" },
+	{ HDA_CODEC_IDT92HD005, "IDT 92HD005" },
+	{ HDA_CODEC_IDT92HD005D, "IDT 92HD005D" },
+	{ HDA_CODEC_IDT92HD206X, "IDT 92HD206X" },
+	{ HDA_CODEC_IDT92HD206D, "IDT 92HD206D" },
+	{ HDA_CODEC_IDT92HD700X, "IDT 92HD700X" },
+	{ HDA_CODEC_IDT92HD700D, "IDT 92HD700D" },
+	{ HDA_CODEC_IDT92HD71B5, "IDT 92HD71B5" },
+	{ HDA_CODEC_IDT92HD71B7, "IDT 92HD71B7" },
+	{ HDA_CODEC_IDT92HD71B8, "IDT 92HD71B8" },
+	{ HDA_CODEC_IDT92HD73C1, "IDT 92HD73C1" },
+	{ HDA_CODEC_IDT92HD73D1, "IDT 92HD73D1" },
+	{ HDA_CODEC_IDT92HD73E1, "IDT 92HD73E1" },
+	{ HDA_CODEC_IDT92HD75B3, "IDT 92HD75B3" },
+	{ HDA_CODEC_IDT92HD75BX, "IDT 92HD75BX" },
+	{ HDA_CODEC_IDT92HD81B1C, "IDT 92HD81B1C" },
+	{ HDA_CODEC_IDT92HD81B1X, "IDT 92HD81B1X" },
+	{ HDA_CODEC_IDT92HD83C1C, "IDT 92HD83C1C" },
+	{ HDA_CODEC_IDT92HD83C1X, "IDT 92HD83C1X" },
 	{ HDA_CODEC_CXVENICE,  "Conexant Venice" },
 	{ HDA_CODEC_CXWAIKIKI, "Conexant Waikiki" },
 	{ HDA_CODEC_VT1708_8,  "VIA VT1708_8" },
@@ -701,6 +780,8 @@ static const struct {
 	{ HDA_CODEC_VTXXXX,    "VIA (Unknown)" },
 	{ HDA_CODEC_ATIXXXX,   "ATI (Unknown)" },
 	{ HDA_CODEC_NVIDIAXXXX,"NVidia (Unknown)" },
+	{ HDA_CODEC_INTELXXXX, "Intel (Unknown)" },
+	{ HDA_CODEC_IDTXXXX,   "IDT (Unknown)" },
 };
 #define HDAC_CODECS_LEN	(sizeof(hdac_codecs) / sizeof(hdac_codecs[0]))
 
@@ -4340,9 +4421,9 @@ static const struct {
 	    HDA_QUIRK_GPIO0 | HDA_QUIRK_OVREF50, 0},
 	{ APPLE_INTEL_MAC, HDA_CODEC_STAC9221,
 	    HDA_QUIRK_GPIO0 | HDA_QUIRK_GPIO1, 0 },
-	{ DELL_D630_SUBVENDOR, HDA_CODEC_STAC9205,
+	{ DELL_D630_SUBVENDOR, HDA_CODEC_STAC9205X,
 	    HDA_QUIRK_GPIO0, 0 },
-	{ DELL_V1500_SUBVENDOR, HDA_CODEC_STAC9205,
+	{ DELL_V1500_SUBVENDOR, HDA_CODEC_STAC9205X,
 	    HDA_QUIRK_GPIO0, 0 },
 	{ HDA_MATCH_ALL, HDA_CODEC_AD1988,
 	    HDA_QUIRK_IVREF80, HDA_QUIRK_IVREF50 | HDA_QUIRK_IVREF100 },
From marius at FreeBSD.org  Tue Oct 14 20:18:57 2008
From: marius at FreeBSD.org (Marius Strobl)
Date: Tue Oct 14 20:19:13 2008
Subject: svn commit: r183895 - head/sys/dev/sym
Message-ID: <200810142018.m9EKIvZw015293@svn.freebsd.org>

Author: marius
Date: Tue Oct 14 20:18:57 2008
New Revision: 183895
URL: http://svn.freebsd.org/changeset/base/183895

Log:
  Use xpt_register_async() in order to remove code duplication.
  
  MFC after:	1 month

Modified:
  head/sys/dev/sym/sym_hipd.c

Modified: head/sys/dev/sym/sym_hipd.c
==============================================================================
--- head/sys/dev/sym/sym_hipd.c	Tue Oct 14 19:58:26 2008	(r183894)
+++ head/sys/dev/sym/sym_hipd.c	Tue Oct 14 20:18:57 2008	(r183895)
@@ -8974,7 +8974,6 @@ static int sym_cam_attach(hcb_p np)
 	struct cam_devq *devq = NULL;
 	struct cam_sim *sim = NULL;
 	struct cam_path *path = NULL;
-	struct ccb_setasync csa;
 	int err;
 
 	/*
@@ -9021,12 +9020,9 @@ static int sym_cam_attach(hcb_p np)
 	/*
 	 *  Establish our async notification handler.
 	 */
-	xpt_setup_ccb(&csa.ccb_h, np->path, 5);
-	csa.ccb_h.func_code = XPT_SASYNC_CB;
-	csa.event_enable    = AC_LOST_DEVICE;
-	csa.callback	    = sym_async;
-	csa.callback_arg    = np->sim;
-	xpt_action((union ccb *)&csa);
+	if (xpt_register_async(AC_LOST_DEVICE, sym_async, sim, path) !=
+	    CAM_REQ_CMP)
+		goto fail;
 
 	/*
 	 *  Start the chip now, without resetting the BUS, since
From marius at FreeBSD.org  Tue Oct 14 20:28:43 2008
From: marius at FreeBSD.org (Marius Strobl)
Date: Tue Oct 14 20:28:54 2008
Subject: svn commit: r183896 - head/sys/dev/bge
Message-ID: <200810142028.m9EKShoL015514@svn.freebsd.org>

Author: marius
Date: Tue Oct 14 20:28:42 2008
New Revision: 183896
URL: http://svn.freebsd.org/changeset/base/183896

Log:
  Use bus_{read,write}_4(9) instead of bus_space_{read,write}_4(9)
  in order to get rid of the bus space handle and tag in the softc.
  
  MFC after:	1 month

Modified:
  head/sys/dev/bge/if_bge.c
  head/sys/dev/bge/if_bgereg.h

Modified: head/sys/dev/bge/if_bge.c
==============================================================================
--- head/sys/dev/bge/if_bge.c	Tue Oct 14 20:18:57 2008	(r183895)
+++ head/sys/dev/bge/if_bge.c	Tue Oct 14 20:28:42 2008	(r183896)
@@ -2377,11 +2377,7 @@ bge_attach(device_t dev)
 		goto fail;
 	}
 
-	sc->bge_btag = rman_get_bustag(sc->bge_res);
-	sc->bge_bhandle = rman_get_bushandle(sc->bge_res);
-
 	/* Save ASIC rev. */
-
 	sc->bge_chipid =
 	    pci_read_config(dev, BGE_PCI_MISC_CTL, 4) &
 	    BGE_PCIMISCCTL_ASICREV;

Modified: head/sys/dev/bge/if_bgereg.h
==============================================================================
--- head/sys/dev/bge/if_bgereg.h	Tue Oct 14 20:18:57 2008	(r183895)
+++ head/sys/dev/bge/if_bgereg.h	Tue Oct 14 20:28:42 2008	(r183896)
@@ -1896,8 +1896,7 @@ struct bge_rcb {
 };
 
 #define	RCB_WRITE_4(sc, rcb, offset, val) \
-	bus_space_write_4(sc->bge_btag, sc->bge_bhandle, \
-			  rcb + offsetof(struct bge_rcb, offset), val)
+	bus_write_4(sc->bge_res, rcb + offsetof(struct bge_rcb, offset), val)
 #define	BGE_RCB_MAXLEN_FLAGS(maxlen, flags)	((maxlen) << 16 | (flags))
 
 #define	BGE_RCB_FLAG_USE_EXT_RX_BD	0x0001
@@ -2394,10 +2393,10 @@ struct bge_gib {
  */
 
 #define	CSR_WRITE_4(sc, reg, val)	\
-	bus_space_write_4(sc->bge_btag, sc->bge_bhandle, reg, val)
+	bus_write_4(sc->bge_res, reg, val)
 
 #define	CSR_READ_4(sc, reg)		\
-	bus_space_read_4(sc->bge_btag, sc->bge_bhandle, reg)
+	bus_read_4(sc->bge_res, reg)
 
 #define	BGE_SETBIT(sc, reg, x)	\
 	CSR_WRITE_4(sc, reg, (CSR_READ_4(sc, reg) | (x)))
@@ -2522,8 +2521,6 @@ struct bge_softc {
 	device_t		bge_dev;
 	struct mtx		bge_mtx;
 	device_t		bge_miibus;
-	bus_space_handle_t	bge_bhandle;
-	bus_space_tag_t		bge_btag;
 	void			*bge_intrhand;
 	struct resource		*bge_irq;
 	struct resource		*bge_res;
From attilio at freebsd.org  Tue Oct 14 20:45:13 2008
From: attilio at freebsd.org (Attilio Rao)
Date: Tue Oct 14 20:45:44 2008
Subject: svn commit: r183866 - head/sys/dev/usb
In-Reply-To: <200810140705.m9E75K3x098307@svn.freebsd.org>
References: <200810140705.m9E75K3x098307@svn.freebsd.org>
Message-ID: <3bbf2fe10810141322o5ee27a2eka8a3a902ced6fc97@mail.gmail.com>

2008/10/14, Rafal Jaworowski :
> Author: raj
>  Date: Tue Oct 14 07:05:20 2008
>  New Revision: 183866
>  URL: http://svn.freebsd.org/changeset/base/183866
>
>  Log:
>   Mbus attachment for USB EHCI integrated controller on Marvell chips.
>
>   This includes workarounds required for the ehci(4) to handle some non-standard
>   behaviour of these devices.
>
>   Obtained from:        Marvell, Semihalf
>
>  Added:
>   head/sys/dev/usb/ehci_mbus.c   (contents, props changed)
>  Modified:
>   head/sys/dev/usb/ehci.c
>   head/sys/dev/usb/ehcivar.h
>
>  Modified: head/sys/dev/usb/ehci.c
>  ==============================================================================
>  --- head/sys/dev/usb/ehci.c     Tue Oct 14 04:09:33 2008        (r183865)
>  +++ head/sys/dev/usb/ehci.c     Tue Oct 14 07:05:20 2008        (r183866)
>  @@ -351,8 +351,12 @@ ehci_hcreset(ehci_softc_t *sc)
>         for (i = 0; i < 100; i++) {
>                 usb_delay_ms(&sc->sc_bus, 1);
>                 hcr = EOREAD4(sc, EHCI_USBCMD) & EHCI_CMD_HCRESET;
>  -               if (!hcr)
>  +               if (!hcr) {
>  +                       if (sc->sc_flags & EHCI_SCFLG_SETMODE)
>  +                               EOWRITE4(sc,  0x68, 0x3);
>  +
>                         return (USBD_NORMAL_COMPLETION);
>  +               }
>         }
>         printf("%s: reset timeout\n", device_get_nameunit(sc->sc_bus.bdev));
>         return (USBD_IOERROR);
>  @@ -2194,7 +2198,18 @@ ehci_root_ctrl_start(usbd_xfer_handle xf
>                 v = EOREAD4(sc, EHCI_PORTSC(index));
>                 DPRINTFN(8,("ehci_root_ctrl_start: port status=0x%04x\n",
>                             v));
>  +
>                 i = UPS_HIGH_SPEED;
>  +
>  +               if (sc->sc_flags & EHCI_SCFLG_FORCESPEED) {
>  +                       if ((v & 0xc000000) == 0x8000000)
>  +                               i = UPS_HIGH_SPEED;
>  +                       else if ((v & 0xc000000) == 0x4000000)
>  +                               i = UPS_LOW_SPEED;
>  +                       else
>  +                               i = 0;
>  +               }
>  +
>                 if (v & EHCI_PS_CS)     i |= UPS_CURRENT_CONNECT_STATUS;
>                 if (v & EHCI_PS_PE)     i |= UPS_PORT_ENABLED;
>                 if (v & EHCI_PS_SUSP)   i |= UPS_SUSPEND;
>  @@ -2249,7 +2264,11 @@ ehci_root_ctrl_start(usbd_xfer_handle xf
>                                 goto ret;
>                         }
>                         /* Terminate reset sequence. */
>  -                       EOWRITE4(sc, port, v);
>  +                       if (sc->sc_flags & EHCI_SCFLG_NORESTERM)
>  +                               ;
>  +                       else
>  +                               EOWRITE4(sc, port, v);
>  +
>                         /* Wait for HC to complete reset. */
>                         usb_delay_ms(&sc->sc_bus, EHCI_PORT_RESET_COMPLETE);
>                         if (sc->sc_dying) {
>
>  Added: head/sys/dev/usb/ehci_mbus.c
>  ==============================================================================
>  --- /dev/null   00:00:00 1970   (empty, because file is newly added)
>  +++ head/sys/dev/usb/ehci_mbus.c        Tue Oct 14 07:05:20 2008        (r183866)
>  @@ -0,0 +1,318 @@
>  +/*-
>  + * Copyright (C) 2008 MARVELL INTERNATIONAL LTD.
>  + * All rights reserved.
>  + *
>  + * Developed by Semihalf.
>  + *
>  + * Redistribution and use in source and binary forms, with or without
>  + * modification, are permitted provided that the following conditions
>  + * are met:
>  + * 1. Redistributions of source code must retain the above copyright
>  + *    notice, this list of conditions and the following disclaimer.
>  + * 2. Redistributions in binary form must reproduce the above copyright
>  + *    notice, this list of conditions and the following disclaimer in the
>  + *    documentation and/or other materials provided with the distribution.
>  + * 3. Neither the name of MARVELL nor the names of contributors
>  + *    may be used to endorse or promote products derived from this software
>  + *    without specific prior written permission.
>  + *
>  + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
>  + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
>  + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
>  + * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
>  + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
>  + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
>  + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
>  + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
>  + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
>  + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  + * SUCH DAMAGE.
>  + */
>  +
>  +/*
>  + * MBus attachment driver for the USB Enhanced Host Controller.
>  + */
>  +
>  +#include 
>  +__FBSDID("$FreeBSD$");
>  +
>  +#include "opt_bus.h"
>  +
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 

Why this includes lockmgr?
I don't think it needs.

Thanks,
Attilio


-- 
Peace can only be achieved by understanding - A. Einstein
From scottl at samsco.org  Tue Oct 14 21:20:52 2008
From: scottl at samsco.org (Scott Long)
Date: Tue Oct 14 21:21:03 2008
Subject: svn commit: r183896 - head/sys/dev/bge
In-Reply-To: <200810142028.m9EKShoL015514@svn.freebsd.org>
References: <200810142028.m9EKShoL015514@svn.freebsd.org>
Message-ID: <48F5053D.7070705@samsco.org>

Marius Strobl wrote:
> Author: marius
> Date: Tue Oct 14 20:28:42 2008
> New Revision: 183896
> URL: http://svn.freebsd.org/changeset/base/183896
> 
> Log:
>   Use bus_{read,write}_4(9) instead of bus_space_{read,write}_4(9)
>   in order to get rid of the bus space handle and tag in the softc.
>   

Has anyone looked at the generated code from this interface switch and
compared it what was getting generated previously?  Way back when,
including  made bus_space_read|write_4() compile
into a direct memory access on machines that supported it.  The dubious
removal of bus_memio.h and bus_pio.h took away that benefit, and I'm
afraid that it's only getting worse now.  Bus writes to card memory are
still very important to high-performance devices and shouldn't be
pessimized in the name of simpler-looking C code.

Scott
From bzeeb-lists at lists.zabbadoz.net  Tue Oct 14 21:22:33 2008
From: bzeeb-lists at lists.zabbadoz.net (Bjoern A. Zeeb)
Date: Tue Oct 14 21:24:00 2008
Subject: cvs commit: src/sys/net if_enc.c if_enc.h src/sys/netipsec 
 ipsec_input.c ipsec_output.c
In-Reply-To: <200808301027.m7UARLZr010667@repoman.freebsd.org>
References: <200808301027.m7UARLZr010667@repoman.freebsd.org>
Message-ID: <20081014205902.U2978@maildrop.int.zabbadoz.net>

On Sat, 30 Aug 2008, VANHULLEBUS Yvan wrote:

> vanhu       2008-08-30 10:25:57 UTC
>
>  FreeBSD src repository
>
>  Modified files:        (Branch: RELENG_7)
>    sys/net              if_enc.c
>    sys/netipsec         ipsec_input.c ipsec_output.c
>  Added files:           (Branch: RELENG_7)
>    sys/net              if_enc.h
>  Log:
>  SVN rev 182472 on 2008-08-30 10:25:57Z by vanhu
>
>  MFC: Increase statistic counters for enc0 interface when enabled
>  and processing IPSec traffic.
>
>  Approved by:    gnn (mentor)
>
>  Revision  Changes    Path
>  1.6.2.2   +1 -1      src/sys/net/if_enc.c
>  1.1.2.1   +35 -0     src/sys/net/if_enc.h (new)
>  1.19.2.1  +8 -0      src/sys/netipsec/ipsec_input.c
>  1.16.2.2  +8 -0      src/sys/netipsec/ipsec_output.c


It seems this MFC was incomplete?

I miss the counters is:
 	ipsec6_output_tunnel():
 	- http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/netipsec/ipsec_output.c.diff?r1=1.19;r2=1.20
 	- http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/netipsec/ipsec_output.c.diff?r1=1.16.2.1;r2=1.16.2.2

 	ipsec6_common_input_cb():
 	- http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/netipsec/ipsec_input.c.diff?r1=1.21;r2=1.22
 	- http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/netipsec/ipsec_input.c.diff?r1=1.19;r2=1.19.2.1

Was that on purpose?

/bz

-- 
Bjoern A. Zeeb              Stop bit received. Insert coin for new game.
From nwhitehorn at FreeBSD.org  Wed Oct 15 03:38:03 2008
From: nwhitehorn at FreeBSD.org (Nathan Whitehorn)
Date: Wed Oct 15 03:38:15 2008
Subject: svn commit: r183901 - head/sys/powerpc/ofw
Message-ID: <200810150338.m9F3c3qr023144@svn.freebsd.org>

Author: nwhitehorn
Date: Wed Oct 15 03:38:03 2008
New Revision: 183901
URL: http://svn.freebsd.org/changeset/base/183901

Log:
  Prevent the OF syscons module from trying to attach to real devices on the
  nexus by only attaching to a device with no OF node.

Modified:
  head/sys/powerpc/ofw/ofw_syscons.c

Modified: head/sys/powerpc/ofw/ofw_syscons.c
==============================================================================
--- head/sys/powerpc/ofw/ofw_syscons.c	Wed Oct 15 00:54:57 2008	(r183900)
+++ head/sys/powerpc/ofw/ofw_syscons.c	Wed Oct 15 03:38:03 2008	(r183901)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 #include 
 
@@ -845,6 +846,10 @@ ofwfb_scidentify(driver_t *driver, devic
 static int
 ofwfb_scprobe(device_t dev)
 {
+	/* This is a fake device, so make sure there is no OF node for it */
+	if (ofw_bus_get_node(dev) != -1)
+		return ENXIO;
+	
 	device_set_desc(dev, "System console");
 	return (sc_probe_unit(device_get_unit(dev), 
 	    device_get_flags(dev) | SC_AUTODETECT_KBD));
From davidxu at FreeBSD.org  Wed Oct 15 06:31:37 2008
From: davidxu at FreeBSD.org (David Xu)
Date: Wed Oct 15 06:31:49 2008
Subject: svn commit: r183911 - in head/sys: kern sys
Message-ID: <200810150631.m9F6VbTG026574@svn.freebsd.org>

Author: davidxu
Date: Wed Oct 15 06:31:37 2008
New Revision: 183911
URL: http://svn.freebsd.org/changeset/base/183911

Log:
  Move per-thread userland debugging flags into seperated field,
  this eliminates some problems of locking, e.g, a thread lock is needed
  but can not be used at that time. Only the process lock is needed now
  for new field.

Modified:
  head/sys/kern/kern_exit.c
  head/sys/kern/kern_sig.c
  head/sys/kern/kern_thread.c
  head/sys/kern/sys_process.c
  head/sys/sys/proc.h

Modified: head/sys/kern/kern_exit.c
==============================================================================
--- head/sys/kern/kern_exit.c	Wed Oct 15 06:21:54 2008	(r183910)
+++ head/sys/kern/kern_exit.c	Wed Oct 15 06:31:37 2008	(r183911)
@@ -438,7 +438,11 @@ exit1(struct thread *td, int rv)
 		 * since their existence means someone is screwing up.
 		 */
 		if (q->p_flag & P_TRACED) {
+			struct thread *temp;
+
 			q->p_flag &= ~(P_TRACED | P_STOPPED_TRACE);
+			FOREACH_THREAD_IN_PROC(q, temp)
+				temp->td_dbgflags &= ~TDB_SUSPEND;
 			psignal(q, SIGKILL);
 		}
 		PROC_UNLOCK(q);

Modified: head/sys/kern/kern_sig.c
==============================================================================
--- head/sys/kern/kern_sig.c	Wed Oct 15 06:21:54 2008	(r183910)
+++ head/sys/kern/kern_sig.c	Wed Oct 15 06:31:37 2008	(r183911)
@@ -2342,16 +2342,12 @@ ptracestop(struct thread *td, int sig)
 	WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK,
 	    &p->p_mtx.lock_object, "Stopping for traced signal");
 
-	thread_lock(td);
-	td->td_flags |= TDF_XSIG;
-	thread_unlock(td);
+	td->td_dbgflags |= TDB_XSIG;
 	td->td_xsig = sig;
 	PROC_SLOCK(p);
-	while ((p->p_flag & P_TRACED) && (td->td_flags & TDF_XSIG)) {
+	while ((p->p_flag & P_TRACED) && (td->td_dbgflags & TDB_XSIG)) {
 		if (p->p_flag & P_SINGLE_EXIT) {
-			thread_lock(td);
-			td->td_flags &= ~TDF_XSIG;
-			thread_unlock(td);
+			td->td_dbgflags &= ~TDB_XSIG;
 			PROC_SUNLOCK(p);
 			return (sig);
 		}
@@ -2368,7 +2364,7 @@ stopme:
 		if (!(p->p_flag & P_TRACED)) {
 			break;
 		}
-		if (td->td_flags & TDF_DBSUSPEND) {
+		if (td->td_dbgflags & TDB_SUSPEND) {
 			if (p->p_flag & P_SINGLE_EXIT)
 				break;
 			goto stopme;

Modified: head/sys/kern/kern_thread.c
==============================================================================
--- head/sys/kern/kern_thread.c	Wed Oct 15 06:21:54 2008	(r183910)
+++ head/sys/kern/kern_thread.c	Wed Oct 15 06:31:37 2008	(r183911)
@@ -563,8 +563,6 @@ thread_single(int mode)
 			if (TD_IS_INHIBITED(td2)) {
 				switch (mode) {
 				case SINGLE_EXIT:
-					if (td->td_flags & TDF_DBSUSPEND)
-						td->td_flags &= ~TDF_DBSUSPEND;
 					if (TD_IS_SUSPENDED(td2))
 						wakeup_swapper |=
 						    thread_unsuspend_one(td2);
@@ -685,7 +683,7 @@ thread_suspend_check(int return_instead)
 	mtx_assert(&Giant, MA_NOTOWNED);
 	PROC_LOCK_ASSERT(p, MA_OWNED);
 	while (P_SHOULDSTOP(p) ||
-	      ((p->p_flag & P_TRACED) && (td->td_flags & TDF_DBSUSPEND))) {
+	      ((p->p_flag & P_TRACED) && (td->td_dbgflags & TDB_SUSPEND))) {
 		if (P_SHOULDSTOP(p) == P_STOPPED_SINGLE) {
 			KASSERT(p->p_singlethread != NULL,
 			    ("singlethread not set"));

Modified: head/sys/kern/sys_process.c
==============================================================================
--- head/sys/kern/sys_process.c	Wed Oct 15 06:21:54 2008	(r183910)
+++ head/sys/kern/sys_process.c	Wed Oct 15 06:31:37 2008	(r183911)
@@ -700,15 +700,14 @@ kern_ptrace(struct thread *td, int req, 
 		break;
 
 	case PT_SUSPEND:
+		td2->td_dbgflags |= TDB_SUSPEND;
 		thread_lock(td2);
-		td2->td_flags |= TDF_DBSUSPEND;
+		td2->td_flags |= TDF_NEEDSUSPCHK;
 		thread_unlock(td2);
 		break;
 
 	case PT_RESUME:
-		thread_lock(td2);
-		td2->td_flags &= ~TDF_DBSUSPEND;
-		thread_unlock(td2);
+		td2->td_dbgflags &= ~TDB_SUSPEND;
 		break;
 
 	case PT_STEP:
@@ -782,17 +781,13 @@ kern_ptrace(struct thread *td, int req, 
 		p->p_xthread = NULL;
 		if ((p->p_flag & (P_STOPPED_SIG | P_STOPPED_TRACE)) != 0) {
 			/* deliver or queue signal */
-			thread_lock(td2);
-			td2->td_flags &= ~TDF_XSIG;
-			thread_unlock(td2);
+			td2->td_dbgflags &= ~TDB_XSIG;
 			td2->td_xsig = data;
 
 			if (req == PT_DETACH) {
 				struct thread *td3;
 				FOREACH_THREAD_IN_PROC(p, td3) {
-					thread_lock(td3);
-					td3->td_flags &= ~TDF_DBSUSPEND; 
-					thread_unlock(td3);
+					td3->td_dbgflags &= ~TDB_SUSPEND; 
 				}
 			}
 			/*
@@ -932,7 +927,7 @@ kern_ptrace(struct thread *td, int req, 
 		}
 		pl = addr;
 		pl->pl_lwpid = td2->td_tid;
-		if (td2->td_flags & TDF_XSIG)
+		if (td2->td_dbgflags & TDB_XSIG)
 			pl->pl_event = PL_EVENT_SIGNAL;
 		else
 			pl->pl_event = 0;

Modified: head/sys/sys/proc.h
==============================================================================
--- head/sys/sys/proc.h	Wed Oct 15 06:21:54 2008	(r183910)
+++ head/sys/sys/proc.h	Wed Oct 15 06:31:37 2008	(r183911)
@@ -232,6 +232,7 @@ struct thread {
 	u_int		td_profil_ticks; /* (k) Temporary ticks until AST. */
 	char		td_name[MAXCOMLEN + 1];	/* (*) Thread name. */
 	struct file	*td_fpop;	/* (k) file referencing cdev under op */
+	int		td_dbgflags;	/* (c) Userland debugger flags */
 #define	td_endzero td_base_pri
 
 /* Copied during fork1() or thread_sched_upcall(). */
@@ -318,10 +319,10 @@ do {									\
 #define	TDF_NEEDSUSPCHK	0x00008000 /* Thread may need to suspend. */
 #define	TDF_NEEDRESCHED	0x00010000 /* Thread needs to yield. */
 #define	TDF_NEEDSIGCHK	0x00020000 /* Thread may need signal delivery. */
-#define	TDF_XSIG	0x00040000 /* Thread is exchanging signal under trace */
+#define	TDF_UNUSED18	0x00040000 /* --available-- */
 #define	TDF_UNUSED19	0x00080000 /* Thread is sleeping on a umtx. */
 #define	TDF_THRWAKEUP	0x00100000 /* Libthr thread must not suspend itself. */
-#define	TDF_DBSUSPEND	0x00200000 /* Thread is suspended by debugger */
+#define	TDF_UNUSED21	0x00200000 /* --available-- */
 #define	TDF_SWAPINREQ	0x00400000 /* Swapin request due to wakeup. */
 #define	TDF_UNUSED23	0x00800000 /* --available-- */
 #define	TDF_SCHED0	0x01000000 /* Reserved for scheduler private use */
@@ -332,6 +333,10 @@ do {									\
 #define	TDF_PROFPEND	0x20000000 /* Pending SIGPROF needs to be posted. */
 #define	TDF_MACPEND	0x40000000 /* AST-based MAC event pending. */
 
+/* Userland debug flags */
+#define	TDB_SUSPEND	0x00000001 /* Thread is suspended by debugger */
+#define	TDB_XSIG	0x00000002 /* Thread is exchanging signal under trace */
+
 /*
  * "Private" flags kept in td_pflags:
  * These are only written by curthread and thus need no locking.
From scottl at samsco.org  Wed Oct 15 10:08:29 2008
From: scottl at samsco.org (Scott Long)
Date: Wed Oct 15 10:08:39 2008
Subject: svn commit: r183896 - head/sys/dev/bge
In-Reply-To: <20081015184833.N43215@delplex.bde.org>
References: <200810142028.m9EKShoL015514@svn.freebsd.org>
	<48F5053D.7070705@samsco.org>
	<20081015184833.N43215@delplex.bde.org>
Message-ID: <48F5C118.3040209@samsco.org>

Bruce Evans wrote:
> On Tue, 14 Oct 2008, Scott Long wrote:
> 
>> Marius Strobl wrote:
>>> Author: marius
>>> Date: Tue Oct 14 20:28:42 2008
>>> New Revision: 183896
>>> URL: http://svn.freebsd.org/changeset/base/183896
>>>
>>> Log:
>>>   Use bus_{read,write}_4(9) instead of bus_space_{read,write}_4(9)
>>>   in order to get rid of the bus space handle and tag in the softc.
>>
>> Has anyone looked at the generated code from this interface switch and
>> compared it what was getting generated previously?  Way back when,
> 
> I just looked at the source code.  This seems to be only a small
> pessimization since it involves just one extra indirection and
> related loss of optimization possibilities: (sc->sc_bt, sc->sc_bh)
> becomes r = sc->sc_br; (r->r_bustag, r->r_bushandle).  In theory,
> the compiler could optimize by caching the tag and handle in registers
> in either case so that only 1 extra indirection is needed per function,
> but I've never seen that being done enough to make much difference.
> 
> However, some drivers (e.g., ata) were too stupid to cache sc_bt and
> sc_bh, and converting these to use bus_nonspace*() was a relatively large
> optimization: r = sc->sc_br; (rman_get_bustag(r), rman_get_bushandle(r))
> became r = sc->sc_br; (r->r_bustag, r->r_bushandle).  Since 
> rman_get_bustag()
> and rman_get_bushandle() have never been inline, calling both of them
> on every bus space access gave enormous code space and instruction
> count bloat and corresponding (relatively tiny) runtime bloat.  The
> instructions normally run so much faster than the i/o that you can do
> hundreds or thousands of them per i/o before noticing the runtime
> bloat, and the instruction count bloat here is only about a factor of 20.

It'll be a long time before disk i/o is fast enough to saturate the CPU
to the point of this issue being important.  Even the fastest SAS
hardware that I've written a driver for struggles to get over 100,000
transactions/sec before saturating the attached disks, leaving plenty
of CPU remaining.

> 
>> including  made bus_space_read|write_4() compile
>> into a direct memory access on machines that supported it.  The dubious
>> removal of bus_memio.h and bus_pio.h took away that benefit, and I'm
>> afraid that it's only getting worse now.  Bus writes to card memory are
>> still very important to high-performance devices and shouldn't be
>> pessimized in the name of simpler-looking C code.
> 
> I hate the bloat too, but it rarely matters (see above).  I mainly noticed
> it using ddb.  Where nice drivers are optimized to use a single instruction
> per i/o (or perhaps 2 with minimal bus space bloat), the ones that use
> rman_get*() on every i/o take 20+, and with a primitive debugger like ddb
> it is painful to even skip over all the function calls.

It's really the opportunity for gratuitous D-cache line misses that
worries me, and to a lesser extend the I-cache bloat, though that's
probably minimal.  In the past I've been able to demonstrate
considerably better micro-performance, and modestly better
macro-performance, in the bge and em drivers from optimizing cache
efficiency in busdma.

> 
> Which devices have fast enough i/o for the extra indirection to matter?
> bge tries hard to avoid all PCI access in time-critical code.  I think
> we reduced the PCI accesses to 1 PCI write per interrupt.  Most device
> accesses for bge use host memory which is DMAed to/from by the hardware,
> so bus space doesn't apply.  This type of access seems to be the best
> or only way for a PCI device to go fast enough (though it is still too
> slow on at least i386 since the DMA always causes cache misses).
> 
> Bruce

I'm thinking of 10Gb ethernet drivers, which have already shown to fully
saturate the host CPU long before wire bandwidth is filled.  I'm only
familiar with cxgb and mxge; cxgb does a single bus write per
transaction, while mxge cheats and aliases the card memory registers via
rman_get_virtual(), making the single-instruction-access automatic =-)

Scott
From brde at optusnet.com.au  Wed Oct 15 10:10:35 2008
From: brde at optusnet.com.au (Bruce Evans)
Date: Wed Oct 15 10:10:46 2008
Subject: svn commit: r183881 - head/sys/netinet
In-Reply-To: <200810141649.04834.max@love2party.net>
References: <200810141226.m9ECQtPW006469@svn.freebsd.org>
	<48F4A9A5.8020605@inse.ru> <200810141649.04834.max@love2party.net>
Message-ID: <20081015195521.J43361@delplex.bde.org>

On Tue, 14 Oct 2008, Max Laier wrote:

> On Tuesday 14 October 2008 16:16:05 Roman Kurakin wrote:
>>> ...
>>> Log:
>>>   o Reformat ipfw nat get|setsockopt code to look it  more
>>>   style(9) compliant.  No functional changes.
>>>
>>> Modified:
>>>   head/sys/netinet/ip_fw2.c
>>>
>>> Modified: head/sys/netinet/ip_fw2.c
>>> =========================================================================
>>> ===== --- head/sys/netinet/ip_fw2.c	Tue Oct 14 10:23:11 2008	(r183880) +++
>>> head/sys/netinet/ip_fw2.c	Tue Oct 14 12:26:55 2008	(r183881) @@ -4385,49
>>> +4385,52 @@ ipfw_ctl(struct sockopt *sopt)
>>>  		break;
>>>
>>>  	case IP_FW_NAT_CFG:
>>> -	{
>>> -		if (IPFW_NAT_LOADED)
>>> -			error = ipfw_nat_cfg_ptr(sopt);
>>> -		else {
>>> -			printf("IP_FW_NAT_CFG: ipfw_nat not present, please load it.\n");
>>> -			error = EINVAL;
>>> +		{
>>> +			if (IPFW_NAT_LOADED)
>>> +				error = ipfw_nat_cfg_ptr(sopt);
>>> ...
>>
>> IMHO such indention does not add any usefulness, but increases indention
>> level that is already very high.
>> Also I do not see strict contradiction to the style(9), but probably I
>> am not reading the most current style(9).

style(9) certainly requires indentation for each level of {}.

> The additional scope is absolutely unnecessary here and should be dropped -
> IMHO.  See case IP_FW_RESETLOG and above.

The bogus {} are probably left over from another style bug -- nested
declarations.  One reason that style(9) forbids nested declarations is
that they require the extra scope (except now using C99 (*)).  Too-large
case statements sometimes want to use different local variables for
each case.  To prevent the indentation reaching column 800, the formatting
in the original version of the above is sometimes used.  But this is just
abnother layer of style bugs if the case statement doesn't even have local
variables.

(*) In C99, you can write:

 	int foo;
 	use (foo);

too easily and not even notice that to properly violate style(9)'s nesting
rule you should have written:

 	{				/* bletch */
 		int foo;

 		use (foo);
 	}

or that to not violate style(9) you should have written:

 	int a, b, c, d, e, f, foo, ...;	/* sort foo into function's decls */
 	...
 	use(foo);

style(9) doesn't allow the C99 declaration since C99 hasn't noticed that
C99 exists.

Bruce
From edwin at FreeBSD.org  Wed Oct 15 12:02:32 2008
From: edwin at FreeBSD.org (Edwin Groothuis)
Date: Wed Oct 15 12:02:39 2008
Subject: svn commit: r183912 - head/release/doc/en_US.ISO8859-1/relnotes
Message-ID: <200810151202.m9FC2WPL033266@svn.freebsd.org>

Author: edwin
Date: Wed Oct 15 12:02:32 2008
New Revision: 183912
URL: http://svn.freebsd.org/changeset/base/183912

Log:
  The timezone information databases has been updated to tzdata2008h.

Modified:
  head/release/doc/en_US.ISO8859-1/relnotes/article.sgml

Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.sgml
==============================================================================
--- head/release/doc/en_US.ISO8859-1/relnotes/article.sgml	Wed Oct 15 06:31:37 2008	(r183911)
+++ head/release/doc/en_US.ISO8859-1/relnotes/article.sgml	Wed Oct 15 12:02:32 2008	(r183912)
@@ -455,8 +455,8 @@
       8.14.1 to 8.14.3.
 
     The timezone database has been updated from
-      the tzdata2007h release to
-      the tzdata2008b release.
+      the tzdata2008b release to
+      the tzdata2008h release.
 
     WPA Supplicant has been
       updated from 0.5.8 to 0.5.10.
From des at des.no  Wed Oct 15 14:02:12 2008
From: des at des.no (=?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?=)
Date: Wed Oct 15 14:02:19 2008
Subject: svn commit: r183881 - head/sys/netinet
In-Reply-To: <20081015195521.J43361@delplex.bde.org> (Bruce Evans's message of
	"Wed, 15 Oct 2008 20:10:21 +1000 (EST)")
References: <200810141226.m9ECQtPW006469@svn.freebsd.org>
	<48F4A9A5.8020605@inse.ru> <200810141649.04834.max@love2party.net>
	<20081015195521.J43361@delplex.bde.org>
Message-ID: <86abd60xel.fsf@ds4.des.no>

Bruce Evans  writes:
> style(9) doesn't allow the C99 declaration since C99 hasn't noticed that
> C99 exists.

I vote for style(9)'s continued ignorance of C99 declarations.

The only case in which I can see a net benefit is for one-off loop
variables, and even there the benefit is probably not sufficient to
justify the loss of compatibility with older compilers.

DES
-- 
Dag-Erling Sm?rgrav - des@des.no
From kensmith at FreeBSD.org  Wed Oct 15 15:54:33 2008
From: kensmith at FreeBSD.org (Ken Smith)
Date: Wed Oct 15 15:54:39 2008
Subject: svn commit: r183921 - head/usr.sbin/sysinstall
Message-ID: <200810151554.m9FFsXGK037543@svn.freebsd.org>

Author: kensmith
Date: Wed Oct 15 15:54:33 2008
New Revision: 183921
URL: http://svn.freebsd.org/changeset/base/183921

Log:
  Package installation is handled by starting off with the list of packages
  the user selected and then recursively installing their dependencies, finally
  installing the ones the user selected after the recursion unwinds.  Since
  users often select "high-level" packages that are on a higher numbered
  disc for the multi-volume release CDROMS this resulted in excessive disc
  swapping while installing things like kde, gnome, etc.
  
  Cut down on disc swapping by iterating through the disc volumes one at a
  time if we notice the package set is on multiple volumes.  If a package
  is on a higher volume don't install it yet, but still "process it" so we
  get its dependencies installed.  Because of the way the package sets for
  releases get assembled we're guaranteed dependencies will be on the same
  volume or lower.
  
  Reviewed by:	jhb
  MFC after:	1 week

Modified:
  head/usr.sbin/sysinstall/config.c
  head/usr.sbin/sysinstall/globals.c
  head/usr.sbin/sysinstall/index.c
  head/usr.sbin/sysinstall/package.c
  head/usr.sbin/sysinstall/sysinstall.h

Modified: head/usr.sbin/sysinstall/config.c
==============================================================================
--- head/usr.sbin/sysinstall/config.c	Wed Oct 15 15:39:20 2008	(r183920)
+++ head/usr.sbin/sysinstall/config.c	Wed Oct 15 15:54:33 2008	(r183921)
@@ -737,6 +737,7 @@ configPackages(dialogMenuItem *self)
 
     while (1) {
 	int ret, pos, scroll;
+	int current, low, high;
 
 	/* Bring up the packages menu */
 	pos = scroll = 0;
@@ -751,8 +752,14 @@ configPackages(dialogMenuItem *self)
 	    else if (DITEM_STATUS(ret) != DITEM_FAILURE) {
 		dialog_clear();
 		restoreflag = 1;
-		for (tmp = Plist.kids; tmp && tmp->name; tmp = tmp->next)
-		    (void)index_extract(mediaDevice, &Top, tmp, FALSE);
+		if (have_volumes) {
+		    low = low_volume;
+		    high = high_volume;
+		} else
+		    low = high = 0;
+		for (current = low; current <= high; current++)
+		    for (tmp = Plist.kids; tmp && tmp->name; tmp = tmp->next)
+		        (void)index_extract(mediaDevice, &Top, tmp, FALSE, current);
 		break;
 	    }
 	}

Modified: head/usr.sbin/sysinstall/globals.c
==============================================================================
--- head/usr.sbin/sysinstall/globals.c	Wed Oct 15 15:39:20 2008	(r183920)
+++ head/usr.sbin/sysinstall/globals.c	Wed Oct 15 15:54:33 2008	(r183921)
@@ -48,10 +48,13 @@ Boolean		DialogActive;	/* Is libdialog i
 Boolean		ColorDisplay;	/* Are we on a color display? */
 Boolean		OnVTY;		/* Are we on a VTY? */
 Boolean		Restarting;	/* Are we restarting sysinstall? */
+Boolean		have_volumes;	/* Media has more than one volume. */
 Variable	*VarHead;	/* The head of the variable chain */
 Device		*mediaDevice;	/* Where we're installing from */
 int		BootMgr;	/* Which boot manager we're using */
 int		StatusLine;	/* Where to stick our status messages */
+int		low_volume;	/* Lowest volume number */
+int		high_volume;	/* Highest volume number */
 jmp_buf		BailOut;	/* Beam me up, scotty! The natives are pissed! */
 
 Chunk		*HomeChunk;

Modified: head/usr.sbin/sysinstall/index.c
==============================================================================
--- head/usr.sbin/sysinstall/index.c	Wed Oct 15 15:39:20 2008	(r183920)
+++ head/usr.sbin/sysinstall/index.c	Wed Oct 15 15:54:33 2008	(r183921)
@@ -225,7 +225,17 @@ new_index(char *name, char *pathto, char
     tmp->deps =		_strdup(deps);
     tmp->depc =		0;
     tmp->installed =	package_installed(name);
+    tmp->vol_checked =	0;
     tmp->volume =	volume;
+    if (volume != 0) {
+	have_volumes = TRUE;
+	if (low_volume == 0)
+	    low_volume = volume;
+	else if (low_volume > volume)
+	    low_volume = volume;
+	if (high_volume < volume)
+	    high_volume = volume;
+    }
     return tmp;
 }
 
@@ -682,9 +692,11 @@ recycle:
 }
 
 int
-index_extract(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended)
+index_extract(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended,
+    int current_volume)
 {
     int status = DITEM_SUCCESS;
+    Boolean notyet = FALSE;
     PkgNodePtr tmp2;
     IndexEntryPtr id = who->data;
     WINDOW *w;
@@ -699,7 +711,7 @@ index_extract(Device *dev, PkgNodePtr to
      * a certain faulty INDEX file. 
      */
 
-    if (id->installed == 1)
+    if (id->installed == 1 || (have_volumes && id->vol_checked == current_volume))
 	return DITEM_SUCCESS;
 
     w = savescr();
@@ -712,9 +724,13 @@ index_extract(Device *dev, PkgNodePtr to
 	    if ((cp2 = index(cp, ' ')) != NULL)
 		*cp2 = '\0';
 	    if ((tmp2 = index_search(top, cp, NULL)) != NULL) {
-		status = index_extract(dev, top, tmp2, TRUE);
+		status = index_extract(dev, top, tmp2, TRUE, current_volume);
 		if (DITEM_STATUS(status) != DITEM_SUCCESS) {
-		    if (variable_get(VAR_NO_CONFIRM))
+		    /* package probably on a future disc volume */
+		    if (status & DITEM_CONTINUE) {
+			status = DITEM_SUCCESS;
+			notyet = TRUE;
+		    } else if (variable_get(VAR_NO_CONFIRM))
 			msgNotify("Loading of dependent package %s failed", cp);
 		    else
 			msgConfirm("Loading of dependent package %s failed", cp);
@@ -732,10 +748,38 @@ index_extract(Device *dev, PkgNodePtr to
 		cp = NULL;
 	}
     }
-    /* Done with the deps?  Load the real m'coy */
+
+    /*
+     * If iterating through disc volumes one at a time indicate failure if
+     * dependency install failed due to package being on a higher volume
+     * numbered disc, but that we should continue anyway.  Note that this
+     * package has already been processed for this disc volume so we don't
+     * need to do it again.
+     */
+
+    if (notyet) {
+    	restorescr(w);
+	id->vol_checked = current_volume;
+	return DITEM_FAILURE | DITEM_CONTINUE;
+    }
+
+    /*
+     * Done with the deps?  Try to load the real m'coy.  If iterating
+     * through a multi-volume disc set fail the install if the package
+     * is on a higher numbered volume to cut down on disc switches the
+     * user needs to do, but indicate caller should continue processing
+     * despite error return.  Note this package was processed for the
+     * current disc being checked.
+     */
+
     if (DITEM_STATUS(status) == DITEM_SUCCESS) {
 	/* Prompt user if the package is not available on the current volume. */
 	if(mediaDevice->type == DEVICE_TYPE_CDROM) {
+	    if (current_volume != 0 && id->volume > current_volume) {
+		restorescr(w);
+		id->vol_checked = current_volume;
+		return DITEM_FAILURE | DITEM_CONTINUE;
+	    }
 	    while (id->volume != dev->volume) {
 		if (!msgYesNo("This is disc #%d.  Package %s is on disc #%d\n"
 			  "Would you like to switch discs now?\n", dev->volume,
@@ -801,6 +845,8 @@ index_initialize(char *path)
     if (!index_initted) {
 	w = savescr();
 	dialog_clear_norefresh();
+	have_volumes = FALSE;
+	low_volume = high_volume = 0;
 
 	/* Got any media? */
 	if (!mediaVerify()) {

Modified: head/usr.sbin/sysinstall/package.c
==============================================================================
--- head/usr.sbin/sysinstall/package.c	Wed Oct 15 15:39:20 2008	(r183920)
+++ head/usr.sbin/sysinstall/package.c	Wed Oct 15 15:54:33 2008	(r183921)
@@ -69,7 +69,7 @@ package_add(char *name)
 
     tmp = index_search(&Top, name, &tmp);
     if (tmp)
-	return index_extract(mediaDevice, &Top, tmp, FALSE);
+	return index_extract(mediaDevice, &Top, tmp, FALSE, 0);
     else {
 	msgConfirm("Sorry, package %s was not found in the INDEX.", name);
 	return DITEM_FAILURE;

Modified: head/usr.sbin/sysinstall/sysinstall.h
==============================================================================
--- head/usr.sbin/sysinstall/sysinstall.h	Wed Oct 15 15:39:20 2008	(r183920)
+++ head/usr.sbin/sysinstall/sysinstall.h	Wed Oct 15 15:54:33 2008	(r183921)
@@ -384,6 +384,7 @@ typedef struct _indexEntry {	/* A single
     char *deps;			/* packages this depends on	*/
     int  depc;			/* how many depend on me	*/
     int  installed;		/* indicates if it is installed */
+    int  vol_checked;		/* disc volume last checked for */
     char *maintainer;		/* maintainer			*/
     unsigned int volume;	/* Volume of package            */
 } IndexEntry;
@@ -416,6 +417,7 @@ extern Boolean		RunningAsInit;		/* Are w
 extern Boolean		DialogActive;		/* Is the dialog() stuff up?			*/
 extern Boolean		ColorDisplay;		/* Are we on a color display?			*/
 extern Boolean		OnVTY;			/* On a syscons VTY?				*/
+extern Boolean		have_volumes;		/* Media has multiple volumes                   */
 extern Variable		*VarHead;		/* The head of the variable chain		*/
 extern Device		*mediaDevice;		/* Where we're getting our distribution from	*/
 extern unsigned int	Dists;			/* Which distributions we want			*/
@@ -479,6 +481,8 @@ extern int              FixItMode;      
 extern const char *	StartName;		/* Which name we were started as */
 extern const char *	ProgName;		/* Program's proper name */
 extern int		NCpus;			/* # cpus on machine */
+extern int		low_volume;		/* Lowest volume number */
+extern int		high_volume;		/* Highest volume number */
 
 /* Important chunks. */
 extern Chunk *HomeChunk;
@@ -670,7 +674,7 @@ void		index_init(PkgNodePtr top, PkgNode
 void		index_node_free(PkgNodePtr top, PkgNodePtr plist);
 void		index_sort(PkgNodePtr top);
 void		index_print(PkgNodePtr top, int level);
-int		index_extract(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended);
+int		index_extract(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended, int current_volume);
 int		index_initialize(char *path);
 PkgNodePtr	index_search(PkgNodePtr top, char *str, PkgNodePtr *tp);
 
From ed at FreeBSD.org  Wed Oct 15 16:58:36 2008
From: ed at FreeBSD.org (Ed Schouten)
Date: Wed Oct 15 16:58:58 2008
Subject: svn commit: r183922 - in head: share/man/man4 sys/kern sys/sys
Message-ID: <200810151658.m9FGwaYZ038854@svn.freebsd.org>

Author: ed
Date: Wed Oct 15 16:58:35 2008
New Revision: 183922
URL: http://svn.freebsd.org/changeset/base/183922

Log:
  Import some improvements to the TTY code from the MPSAFE TTY branch.
  
  - Change the ddb(4) commands to be more useful (by thompsa@):
    - `show ttys' is now called `show all ttys'. This command will now
      also display the address where the TTY data structure resides.
    - Add `show tty ', which dumps the TTY in a readable form.
  
  - Place an upper bound on the TTY buffer sizes. Some drivers do not want
    to care about baud rates. Protect these drivers by preventing the TTY
    buffers from getting enormous. Right now we'll just clamp it to 64K,
    which is pretty high, taking into account that these buffers are only
    used by the built-in discipline.
  
  - Only call ttydev_leave() when needed. Back in April/May the TTY
    reference counting mechanism was a little different, which required us
    to call ttydev_leave() each time we finished a cdev operation.
    Nowadays we only need to call ttydev_leave() when we really mark it as
    being closed.
  
  - Improve return codes of read() and write() on TTY device nodes.
  
  - Make sure we really wake up all blocked threads when the driver calls
    tty_rel_gone(). There were some possible code paths where we didn't
    properly wake up any readers/writers.
  
  - Add extra assertions to prevent sleeping on a TTY that has been
    abandoned by the driver.
  
  - Use ttydev_cdevsw as a more reliable method to figure out whether a
    device node is a real TTY device node.
  
  Obtained from:	//depot/projects/mpsafetty/...
  Reviewed by:	thompsa

Modified:
  head/share/man/man4/ddb.4
  head/sys/kern/tty.c
  head/sys/sys/tty.h

Modified: head/share/man/man4/ddb.4
==============================================================================
--- head/share/man/man4/ddb.4	Wed Oct 15 15:54:33 2008	(r183921)
+++ head/share/man/man4/ddb.4	Wed Oct 15 16:58:35 2008	(r183922)
@@ -540,6 +540,13 @@ modifier will alter the display to show 
 addresses for the process and not show other information.
 .\"
 .Pp
+.It Ic show Cm all ttys
+Show all TTY's within the system.
+Output is similar to
+.Xr pstat 8 ,
+but also includes the address of the TTY structure.
+.\"
+.Pp
 .It Ic show Cm allchains
 Show the same information like "show lockchain" does, but
 for every thread in the system.
@@ -963,10 +970,8 @@ Backtrace.
 .El
 .\"
 .Pp
-.It Ic show Cm ttys
-Show all TTY's within the system.
-Output is similar to
-.Xr pstat 8 .
+.It Ic show Cm tty Ar addr
+Display the contents of a TTY structure in a readable form.
 .\"
 .Pp
 .It Ic show Cm turnstile Ar addr

Modified: head/sys/kern/tty.c
==============================================================================
--- head/sys/kern/tty.c	Wed Oct 15 15:54:33 2008	(r183921)
+++ head/sys/kern/tty.c	Wed Oct 15 16:58:35 2008	(r183922)
@@ -92,21 +92,23 @@ static unsigned int tty_list_count = 0;
  * Set TTY buffer sizes.
  */
 
+#define	TTYBUF_MAX	65536
+
 static void
 tty_watermarks(struct tty *tp)
 {
-	speed_t sp;
+	size_t bs;
 
 	/* Provide an input buffer for 0.2 seconds of data. */
-	sp = MAX(tp->t_termios.c_ispeed, 0);
-	ttyinq_setsize(&tp->t_inq, tp, sp / 5);
+	bs = MIN(tp->t_termios.c_ispeed / 5, TTYBUF_MAX);
+	ttyinq_setsize(&tp->t_inq, tp, bs);
 
 	/* Set low watermark at 10% (when 90% is available). */
 	tp->t_inlow = (ttyinq_getsize(&tp->t_inq) * 9) / 10;
 
 	/* Provide an ouput buffer for 0.2 seconds of data. */
-	sp = MAX(tp->t_termios.c_ospeed, 0);
-	ttyoutq_setsize(&tp->t_outq, tp, sp / 5);
+	bs = MIN(tp->t_termios.c_ospeed / 5, TTYBUF_MAX);
+	ttyoutq_setsize(&tp->t_outq, tp, bs);
 
 	/* Set low watermark at 10% (when 90% is available). */
 	tp->t_outlow = (ttyoutq_getsize(&tp->t_outq) * 9) / 10;
@@ -133,11 +135,12 @@ tty_drain(struct tty *tp)
 }
 
 /*
- * Because the revoke() call already calls d_close() without making sure
- * all threads are purged from the TTY, we can only destroy the buffers
- * and such when the last thread leaves the TTY. ttydev_enter() and
- * ttydev_leave() are called from within the cdev functions, to make
- * sure we can garbage collect the TTY.
+ * Though ttydev_enter() and ttydev_leave() seem to be related, they
+ * don't have to be used together. ttydev_enter() is used by the cdev
+ * operations to prevent an actual operation from being processed when
+ * the TTY has been abandoned. ttydev_leave() is used by ttydev_open()
+ * and ttydev_close() to determine whether per-TTY data should be
+ * deallocated.
  */
 
 static __inline int
@@ -287,6 +290,7 @@ ttydev_open(struct cdev *dev, int oflags
 
 done:	tp->t_flags &= ~TF_OPENCLOSE;
 	ttydev_leave(tp);
+
 	return (error);
 }
 
@@ -378,22 +382,23 @@ ttydev_read(struct cdev *dev, struct uio
 
 	error = ttydev_enter(tp);
 	if (error)
-		return (0);
+		goto done;
 
 	error = tty_wait_background(tp, curthread, SIGTTIN);
-	if (error)
+	if (error) {
+		tty_unlock(tp);
 		goto done;
+	}
 
 	error = ttydisc_read(tp, uio, ioflag);
-done:	ttydev_leave(tp);
+	tty_unlock(tp);
 
 	/*
-	 * The read() and write() calls should not throw an error when
-	 * the device is ripped offline.
+	 * The read() call should not throw an error when the device is
+	 * being destroyed. Silently convert it to an EOF.
 	 */
-	if (error == ENXIO)
-		return (0);
-
+done:	if (error == ENXIO)
+		error = 0;
 	return (error);
 }
 
@@ -405,23 +410,18 @@ ttydev_write(struct cdev *dev, struct ui
 
 	error = ttydev_enter(tp);
 	if (error)
-		return (0);
+		return (error);
 
 	if (tp->t_termios.c_lflag & TOSTOP) {
 		error = tty_wait_background(tp, curthread, SIGTTOU);
-		if (error)
-			goto done;
+		if (error) {
+			tty_unlock(tp);
+			return (error);
+		}
 	}
 
 	error = ttydisc_write(tp, uio, ioflag);
-done:	ttydev_leave(tp);
-
-	/*
-	 * The read() and write() calls should not throw an error when
-	 * the device is ripped offline.
-	 */
-	if (error == ENXIO)
-		return (0);
+	tty_unlock(tp);
 
 	return (error);
 }
@@ -479,7 +479,7 @@ ttydev_ioctl(struct cdev *dev, u_long cm
 	}
 
 	error = tty_ioctl(tp, cmd, data, td);
-done:	ttydev_leave(tp);
+done:	tty_unlock(tp);
 
 	return (error);
 }
@@ -518,7 +518,7 @@ ttydev_poll(struct cdev *dev, int events
 			selrecord(td, &tp->t_outpoll);
 	}
 
-	ttydev_leave(tp);
+	tty_unlock(tp);
 
 	return (revents);
 }
@@ -535,7 +535,7 @@ ttydev_mmap(struct cdev *dev, vm_offset_
 	if (error)
 		return (-1);
 	error = ttydevsw_mmap(tp, offset, paddr, nprot);
-	ttydev_leave(tp);
+	tty_unlock(tp);
 
 	return (error);
 }
@@ -623,7 +623,7 @@ ttydev_kqfilter(struct cdev *dev, struct
 		break;
 	}
 
-	ttydev_leave(tp);
+	tty_unlock(tp);
 	return (error);
 }
 
@@ -973,7 +973,8 @@ tty_rel_gone(struct tty *tp)
 	/* Simulate carrier removal. */
 	ttydisc_modem(tp, 0);
 
-	/* Wake up misc. blocked threads. */
+	/* Wake up all blocked threads. */
+	tty_wakeup(tp, FREAD|FWRITE);
 	cv_broadcast(&tp->t_bgwait);
 	cv_broadcast(&tp->t_dcdwait);
 
@@ -1189,6 +1190,7 @@ tty_wait(struct tty *tp, struct cv *cv)
 	tty_lock_assert(tp, MA_OWNED|MA_NOTRECURSED);
 #endif
 	tty_lock_assert(tp, MA_OWNED);
+	MPASS(!tty_gone(tp));
 
 	error = cv_wait_sig(cv, tp->t_mtx);
 
@@ -1214,6 +1216,7 @@ tty_timedwait(struct tty *tp, struct cv 
 	tty_lock_assert(tp, MA_OWNED|MA_NOTRECURSED);
 #endif
 	tty_lock_assert(tp, MA_OWNED);
+	MPASS(!tty_gone(tp));
 
 	error = cv_timedwait_sig(cv, tp->t_mtx, hz);
 
@@ -1690,7 +1693,7 @@ ttyhook_register(struct tty **rtp, struc
 	cdp = dev_refthread(dev);
 	if (cdp == NULL)
 		goto done1;
-	if ((cdp->d_flags & D_TTY) == 0)
+	if (cdp != &ttydev_cdevsw)
 		goto done2;
 	tp = dev->si_drv1;
 
@@ -1741,6 +1744,7 @@ ttyhook_unregister(struct tty *tp)
 #include "opt_ddb.h"
 #ifdef DDB
 #include 
+#include 
 
 static struct {
 	int flag;
@@ -1776,14 +1780,134 @@ static struct {
 	{ 0,	       '\0' },
 };
 
+#define	TTY_FLAG_BITS \
+	"\20\1NOPREFIX\2INITLOCK\3CALLOUT\4OPENED_IN\5OPENED_OUT\6GONE" \
+	"\7OPENCLOSE\10ASYNC\11LITERAL\12HIWAT_IN\13HIWAT_OUT\14STOPPED" \
+	"\15EXCLUDE\16BYPASS\17ZOMBIE\20HOOK"
+
+#define DB_PRINTSYM(name, addr) \
+	db_printf("%s  " #name ": ", sep); \
+	db_printsym((db_addr_t) addr, DB_STGY_ANY); \
+	db_printf("\n");
+
+static void
+_db_show_devsw(const char *sep, const struct ttydevsw *tsw)
+{
+	db_printf("%sdevsw: ", sep);
+	db_printsym((db_addr_t)tsw, DB_STGY_ANY);
+	db_printf(" (%p)\n", tsw);
+	DB_PRINTSYM(open, tsw->tsw_open);
+	DB_PRINTSYM(close, tsw->tsw_close);
+	DB_PRINTSYM(outwakeup, tsw->tsw_outwakeup);
+	DB_PRINTSYM(inwakeup, tsw->tsw_inwakeup);
+	DB_PRINTSYM(ioctl, tsw->tsw_ioctl);
+	DB_PRINTSYM(param, tsw->tsw_param);
+	DB_PRINTSYM(modem, tsw->tsw_modem);
+	DB_PRINTSYM(mmap, tsw->tsw_mmap);
+	DB_PRINTSYM(pktnotify, tsw->tsw_pktnotify);
+	DB_PRINTSYM(free, tsw->tsw_free);
+}
+static void
+_db_show_hooks(const char *sep, const struct ttyhook *th)
+{
+	db_printf("%shook: ", sep);
+	db_printsym((db_addr_t)th, DB_STGY_ANY);
+	db_printf(" (%p)\n", th);
+	if (th == NULL)
+		return;
+	DB_PRINTSYM(rint, th->th_rint);
+	DB_PRINTSYM(rint_bypass, th->th_rint_bypass);
+	DB_PRINTSYM(rint_done, th->th_rint_done);
+	DB_PRINTSYM(rint_poll, th->th_rint_poll);
+	DB_PRINTSYM(getc_inject, th->th_getc_inject);
+	DB_PRINTSYM(getc_capture, th->th_getc_capture);
+	DB_PRINTSYM(getc_poll, th->th_getc_poll);
+	DB_PRINTSYM(close, th->th_close);
+}
+
+static void
+_db_show_termios(const char *name, const struct termios *t)
+{
+
+	db_printf("%s: iflag 0x%x oflag 0x%x cflag 0x%x "
+	    "lflag 0x%x ispeed %u ospeed %u\n", name,
+	    t->c_iflag, t->c_oflag, t->c_cflag, t->c_lflag,
+	    t->c_ispeed, t->c_ospeed);
+}
+
 /* DDB command to show TTY statistics. */
-DB_SHOW_COMMAND(ttys, db_show_ttys)
+DB_SHOW_COMMAND(tty, db_show_tty)
+{
+	struct tty *tp;
+
+	if (!have_addr) {
+		db_printf("usage: show tty \n");
+		return;
+	}
+	tp = (struct tty *)addr;
+
+	db_printf("0x%p: %s\n", tp, tty_devname(tp));
+	db_printf("\tmtx: %p\n", tp->t_mtx);
+	db_printf("\tflags: %b\n", tp->t_flags, TTY_FLAG_BITS);
+	db_printf("\trevokecnt: %u\n", tp->t_revokecnt);
+
+	/* Buffering mechanisms. */
+	db_printf("\tinq: %p begin %u linestart %u reprint %u end %u "
+	    "nblocks %u quota %u\n", &tp->t_inq, tp->t_inq.ti_begin,
+	    tp->t_inq.ti_linestart, tp->t_inq.ti_reprint, tp->t_inq.ti_end,
+	    tp->t_inq.ti_nblocks, tp->t_inq.ti_quota);
+	db_printf("\toutq: %p begin %u end %u nblocks %u quota %u\n",
+	    &tp->t_outq, tp->t_outq.to_begin, tp->t_outq.to_end,
+	    tp->t_outq.to_nblocks, tp->t_outq.to_quota);
+	db_printf("\tinlow: %zu\n", tp->t_inlow);
+	db_printf("\toutlow: %zu\n", tp->t_outlow);
+	_db_show_termios("\ttermios", &tp->t_termios);
+	db_printf("\twinsize: row %u col %u xpixel %u ypixel %u\n",
+	    tp->t_winsize.ws_row, tp->t_winsize.ws_col,
+	    tp->t_winsize.ws_xpixel, tp->t_winsize.ws_ypixel);
+	db_printf("\tcolumn: %u\n", tp->t_column);
+	db_printf("\twritepos: %u\n", tp->t_writepos);
+	db_printf("\tcompatflags: 0x%x\n", tp->t_compatflags);
+
+	/* Init/lock-state devices. */
+	_db_show_termios("\ttermios_init_in", &tp->t_termios_init_in);
+	_db_show_termios("\ttermios_init_out", &tp->t_termios_init_out);
+	_db_show_termios("\ttermios_lock_in", &tp->t_termios_lock_in);
+	_db_show_termios("\ttermios_lock_out", &tp->t_termios_lock_out);
+
+	/* Hooks */
+	_db_show_devsw("\t", tp->t_devsw);
+	_db_show_hooks("\t", tp->t_hook);
+
+	/* Process info. */
+	db_printf("\tpgrp: %p gid %d jobc %d\n", tp->t_pgrp,
+	    tp->t_pgrp ? tp->t_pgrp->pg_id : 0,
+	    tp->t_pgrp ? tp->t_pgrp->pg_jobc : 0);
+	db_printf("\tsession: %p", tp->t_session);
+	if (tp->t_session != NULL)
+	    db_printf(" count %u leader %p tty %p sid %d login %s",
+		tp->t_session->s_count, tp->t_session->s_leader,
+		tp->t_session->s_ttyp, tp->t_session->s_sid,
+		tp->t_session->s_login);
+	db_printf("\n");
+	db_printf("\tsessioncnt: %u\n", tp->t_sessioncnt);
+	db_printf("\tdevswsoftc: %p\n", tp->t_devswsoftc);
+	db_printf("\thooksoftc: %p\n", tp->t_hooksoftc);
+	db_printf("\tdev: %p\n", tp->t_dev);
+}
+
+/* DDB command to list TTYs. */
+DB_SHOW_ALL_COMMAND(ttys, db_show_all_ttys)
 {
 	struct tty *tp;
 	size_t isiz, osiz;
 	int i, j;
 
 	/* Make the output look like `pstat -t'. */
+	db_printf("PTR        ");
+#if defined(__LP64__)
+	db_printf("        ");
+#endif
 	db_printf("      LINE   INQ  CAN  LIN  LOW  OUTQ  USE  LOW   "
 	    "COL  SESS  PGID STATE\n");
 
@@ -1791,7 +1915,8 @@ DB_SHOW_COMMAND(ttys, db_show_ttys)
 		isiz = tp->t_inq.ti_nblocks * TTYINQ_DATASIZE;
 		osiz = tp->t_outq.to_nblocks * TTYOUTQ_DATASIZE;
 
-		db_printf("%10s %5zu %4u %4u %4zu %5zu %4u %4zu %5u %5d %5d ",
+		db_printf("%p %10s %5zu %4u %4u %4zu %5zu %4u %4zu %5u %5d %5d ",
+		    tp,
 		    tty_devname(tp),
 		    isiz,
 		    tp->t_inq.ti_linestart - tp->t_inq.ti_begin,

Modified: head/sys/sys/tty.h
==============================================================================
--- head/sys/sys/tty.h	Wed Oct 15 15:54:33 2008	(r183921)
+++ head/sys/sys/tty.h	Wed Oct 15 16:58:35 2008	(r183922)
@@ -63,6 +63,7 @@ struct tty {
 	struct mtx	t_mtxobj;	/* Per-TTY lock (when not borrowing). */
 	TAILQ_ENTRY(tty) t_list;	/* (l) TTY list entry. */
 	unsigned int	t_flags;	/* (t) Terminal option flags. */
+/* Keep flags in sync with db_show_tty and pstat(8). */
 #define	TF_NOPREFIX	0x0001	/* Don't prepend "tty" to device name. */
 #define	TF_INITLOCK	0x0002	/* Create init/lock state devices. */
 #define	TF_CALLOUT	0x0004	/* Create "cua" devices. */
From brde at optusnet.com.au  Wed Oct 15 19:00:27 2008
From: brde at optusnet.com.au (Bruce Evans)
Date: Wed Oct 15 19:00:32 2008
Subject: svn commit: r183896 - head/sys/dev/bge
In-Reply-To: <48F5053D.7070705@samsco.org>
References: <200810142028.m9EKShoL015514@svn.freebsd.org>
	<48F5053D.7070705@samsco.org>
Message-ID: <20081015184833.N43215@delplex.bde.org>

On Tue, 14 Oct 2008, Scott Long wrote:

> Marius Strobl wrote:
>> Author: marius
>> Date: Tue Oct 14 20:28:42 2008
>> New Revision: 183896
>> URL: http://svn.freebsd.org/changeset/base/183896
>> 
>> Log:
>>   Use bus_{read,write}_4(9) instead of bus_space_{read,write}_4(9)
>>   in order to get rid of the bus space handle and tag in the softc.
>
> Has anyone looked at the generated code from this interface switch and
> compared it what was getting generated previously?  Way back when,

I just looked at the source code.  This seems to be only a small
pessimization since it involves just one extra indirection and
related loss of optimization possibilities: (sc->sc_bt, sc->sc_bh)
becomes r = sc->sc_br; (r->r_bustag, r->r_bushandle).  In theory,
the compiler could optimize by caching the tag and handle in registers
in either case so that only 1 extra indirection is needed per function,
but I've never seen that being done enough to make much difference.

However, some drivers (e.g., ata) were too stupid to cache sc_bt and
sc_bh, and converting these to use bus_nonspace*() was a relatively large
optimization: r = sc->sc_br; (rman_get_bustag(r), rman_get_bushandle(r))
became r = sc->sc_br; (r->r_bustag, r->r_bushandle).  Since rman_get_bustag()
and rman_get_bushandle() have never been inline, calling both of them
on every bus space access gave enormous code space and instruction
count bloat and corresponding (relatively tiny) runtime bloat.  The
instructions normally run so much faster than the i/o that you can do
hundreds or thousands of them per i/o before noticing the runtime
bloat, and the instruction count bloat here is only about a factor of 20.

> including  made bus_space_read|write_4() compile
> into a direct memory access on machines that supported it.  The dubious
> removal of bus_memio.h and bus_pio.h took away that benefit, and I'm
> afraid that it's only getting worse now.  Bus writes to card memory are
> still very important to high-performance devices and shouldn't be
> pessimized in the name of simpler-looking C code.

I hate the bloat too, but it rarely matters (see above).  I mainly noticed
it using ddb.  Where nice drivers are optimized to use a single instruction
per i/o (or perhaps 2 with minimal bus space bloat), the ones that use
rman_get*() on every i/o take 20+, and with a primitive debugger like ddb
it is painful to even skip over all the function calls.

Which devices have fast enough i/o for the extra indirection to matter?
bge tries hard to avoid all PCI access in time-critical code.  I think
we reduced the PCI accesses to 1 PCI write per interrupt.  Most device
accesses for bge use host memory which is DMAed to/from by the hardware,
so bus space doesn't apply.  This type of access seems to be the best
or only way for a PCI device to go fast enough (though it is still too
slow on at least i386 since the DMA always causes cache misses).

Bruce
From bz at FreeBSD.org  Wed Oct 15 19:24:18 2008
From: bz at FreeBSD.org (Bjoern A. Zeeb)
Date: Wed Oct 15 19:24:34 2008
Subject: svn commit: r183923 - head/sys/netinet6
Message-ID: <200810151924.m9FJOIlW041309@svn.freebsd.org>

Author: bz
Date: Wed Oct 15 19:24:18 2008
New Revision: 183923
URL: http://svn.freebsd.org/changeset/base/183923

Log:
  Check that the mbuf len is positive (like we do in the v4 case).
  
  Read the other way round this means that even with the checks
  the m_len turned negative in some cases which led to panics.
  The reason to my understanding seems to be that the checks are wrong
  (also for v4) ignoring possible padding when checking cmsg_len or
  padding after data when adjusting the mbuf.
  Doing proper cheks seems to break applications like named so
  further investigation and regression tests are needed.
  
  PR:		kern/119123
  Tested by:	Ashish Shukla  wahjava gmail.com
  MFC after:	3 days

Modified:
  head/sys/netinet6/ip6_output.c

Modified: head/sys/netinet6/ip6_output.c
==============================================================================
--- head/sys/netinet6/ip6_output.c	Wed Oct 15 16:58:35 2008	(r183922)
+++ head/sys/netinet6/ip6_output.c	Wed Oct 15 19:24:18 2008	(r183923)
@@ -2820,7 +2820,7 @@ ip6_setpktopts(struct mbuf *control, str
 	if (control->m_next)
 		return (EINVAL);
 
-	for (; control->m_len; control->m_data += CMSG_ALIGN(cm->cmsg_len),
+	for (; control->m_len > 0; control->m_data += CMSG_ALIGN(cm->cmsg_len),
 	    control->m_len -= CMSG_ALIGN(cm->cmsg_len)) {
 		int error;
 
From n_hibma at FreeBSD.org  Wed Oct 15 21:25:12 2008
From: n_hibma at FreeBSD.org (Nick Hibma)
Date: Wed Oct 15 21:25:19 2008
Subject: svn commit: r183925 - head/sys/dev/usb
Message-ID: <200810152125.m9FLPC0H043714@svn.freebsd.org>

Author: n_hibma
Date: Wed Oct 15 21:25:11 2008
New Revision: 183925
URL: http://svn.freebsd.org/changeset/base/183925

Log:
  Rewrite the driver to better support the Huawei devices. It should now support
  the Sierra and Novatel devices, ignore all umass devices and hide the umass
  devices that represent the CD ROM devices (but not the SD card slot in the
  Huawei Mobile dongle).
  
  Note: This driver in FBSD7 seems to suffer from memory corruption when used
  with an Option GT Quad. The E220 however works flawlessly.
  
  Also add the ID for the Option GTMaxHSUPA, provided by Olivier Fromme.

Modified:
  head/sys/dev/usb/u3g.c
  head/sys/dev/usb/ubsa.c
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/u3g.c
==============================================================================
--- head/sys/dev/usb/u3g.c	Wed Oct 15 20:44:00 2008	(r183924)
+++ head/sys/dev/usb/u3g.c	Wed Oct 15 21:25:11 2008	(r183925)
@@ -19,6 +19,14 @@
  * $FreeBSD$
  */
 
+/*
+ * Notes:
+ * - The detour through the tty layer is ridiculously expensive wrt buffering
+ *   due to the high speeds.
+ *   We should consider adding a simple r/w device which allows attaching of PPP
+ *   in a more efficient way.
+ */
+
 #include 
 #include 
 #include 
@@ -40,43 +48,39 @@
 
 #include "usbdevs.h"
 
+#define U3G_DEBUG	1
 #ifdef U3G_DEBUG
-#define DPRINTFN(n, x)	do { if (u3gdebug > (n)) printf x; } while (0)
-int	u3gtebug = 0;
+#define DPRINTF(x...)		do { if (u3gdebug) device_printf(self, ##x); } while (0)
+#define DPRINTFN(n, x...)	do { if (u3gdebug > (n)) device_printf(self, ##x); } while (0)
+int	u3gdebug = 1;
 #else
-#define DPRINTFN(n, x)
+#define DPRINTF(x...)		/* nop */
+#define DPRINTFN(n, x...)	/* nop */
 #endif
-#define DPRINTF(x) DPRINTFN(0, x)
 
-#define U3G_BUFSIZ		1024
+#define U3G_BUFSIZ		10240
 #define U3G_MAXPORTS		4
 #define U3G_CONFIG_INDEX	0
 
 struct u3g_softc {
-	struct ucom_softc	sc_ucom[U3G_MAXPORTS];;
+	struct ucom_softc	sc_ucom[U3G_MAXPORTS];
 	device_t		sc_dev;
 	usbd_device_handle	sc_udev;
-	u_int16_t		sc_flags;
-	u_char			sc_msr;
-	u_char			sc_lsr;
-	u_char			numports;
-
-	usbd_interface_handle	sc_intr_iface;	/* interrupt interface */
-#ifdef U3G_DEBUG
-	int			sc_intr_number;	/* interrupt number */
-	usbd_pipe_handle	sc_intr_pipe;	/* interrupt pipe */
-	u_char			*sc_intr_buf;	/* interrupt buffer */
-#endif
-	int			sc_isize;
+	u_int8_t		sc_speed;
+	u_int8_t		sc_flags;
+	u_char			sc_numports;
 };
 
+static int u3g_open(void *addr, int portno);
+static void u3g_close(void *addr, int portno);
+
 struct ucom_callback u3g_callback = {
 	NULL,
 	NULL,
 	NULL,
 	NULL,
-	NULL,
-	NULL,
+	u3g_open,
+	u3g_close,
 	NULL,
 	NULL,
 };
@@ -86,81 +90,106 @@ struct ucom_callback u3g_callback = {
  * Various supported device vendors/products.
  */
 struct u3g_dev_type_s {
-	struct usb_devno	u3g_dev;
-	u_int16_t		u3g_flags;
-#define U3GFL_NONE		0x0000
-#define U3GFL_HUAWEI_INIT	0x0001		/* Send USB command to reset iface to ucom mode */
+	struct usb_devno	devno;
+	u_int8_t		speed;
+#define U3GSP_GPRS		1
+#define U3GSP_EDGE		2
+#define U3GSP_UMTS		3
+#define U3GSP_HSDPA		4
+#define U3GSP_HSUPA		5
+#define U3GSP_HSPA		6
+
+	u_int8_t		flags;
+#define U3GFL_NONE		0x00
+#define U3GFL_HUAWEI_INIT	0x01		// Requires init (Huawei cards)
+#define U3GFL_STUB_WAIT		0x02		// Device reappears after a short delay
 };
 
 static const struct u3g_dev_type_s u3g_devs[] = {
 	/* OEM: Option */
-	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3G },		U3GFL_NONE },
-	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GQUAD },		U3GFL_NONE },
-	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GPLUS },		U3GFL_NONE },
-	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GTMAX36 },		U3GFL_NONE },
-	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_VODAFONEMC3G },	U3GFL_NONE },
+	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3G },		U3GSP_UMTS,	U3GFL_NONE },
+	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GQUAD },		U3GSP_UMTS,	U3GFL_NONE },
+	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GT3GPLUS },		U3GSP_UMTS,	U3GFL_NONE },
+	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GTMAX36 },		U3GSP_HSDPA,	U3GFL_NONE },
+	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_GTMAXHSUPA },		U3GSP_HSDPA,	U3GFL_NONE },
+	{{ USB_VENDOR_OPTION, USB_PRODUCT_OPTION_VODAFONEMC3G },	U3GSP_UMTS,	U3GFL_NONE },
 	/* OEM: Qualcomm, Inc. */
-	{{ USB_VENDOR_QUALCOMMINC, USB_PRODUCT_QUALCOMMINC_CDMA_MSM },	U3GFL_NONE },
+	{{ USB_VENDOR_QUALCOMMINC, USB_PRODUCT_QUALCOMMINC_CDMA_MSM },	U3GSP_UMTS,	U3GFL_STUB_WAIT },	// XXX
 	/* OEM: Huawei */
-	/* Handled separately. Do not add!
-	{{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_MOBILE },		U3GFL_NONE },
-	{{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220 },		U3GFL_NONE },
-	 */
+	{{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_MOBILE },		U3GSP_HSDPA,	U3GFL_HUAWEI_INIT },
+	{{ USB_VENDOR_HUAWEI, USB_PRODUCT_HUAWEI_E220 },		U3GSP_HSDPA,	U3GFL_HUAWEI_INIT },
 	/* OEM: Novatel */
-	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_CDMA_MODEM },	U3GFL_NONE },
-	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_ES620 },		U3GFL_NONE },
-	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_MC950D },		U3GFL_NONE },
-	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U720 },		U3GFL_NONE },
-	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U727 },		U3GFL_NONE },
-	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740 },		U3GFL_NONE },
-	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740_2 },		U3GFL_NONE },
-	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U870 },		U3GFL_NONE },
-	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V620 },		U3GFL_NONE },
-	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V640 },		U3GFL_NONE },
-	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V720 },		U3GFL_NONE },
-	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V740 },		U3GFL_NONE },
-	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_X950D },		U3GFL_NONE },
-	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_XU870 },		U3GFL_NONE },
-	{{ USB_VENDOR_DELL,    USB_PRODUCT_DELL_U740 },			U3GFL_NONE },
+	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_CDMA_MODEM },	U3GSP_UMTS,	U3GFL_STUB_WAIT },	// XXX
+	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_ES620 },		U3GSP_UMTS,	U3GFL_STUB_WAIT },	// XXX
+	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_MC950D },		U3GSP_HSUPA,	U3GFL_STUB_WAIT },
+	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U720 },		U3GSP_UMTS,	U3GFL_STUB_WAIT },	// XXX
+	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U727 },		U3GSP_UMTS,	U3GFL_STUB_WAIT },	// XXX
+	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740 },		U3GSP_HSDPA,	U3GFL_STUB_WAIT },
+	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U740_2 },		U3GSP_HSDPA,	U3GFL_STUB_WAIT },
+	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_U870 },		U3GSP_UMTS,	U3GFL_STUB_WAIT },	// XXX
+	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V620 },		U3GSP_UMTS,	U3GFL_STUB_WAIT },	// XXX
+	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V640 },		U3GSP_UMTS,	U3GFL_STUB_WAIT },	// XXX
+	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V720 },		U3GSP_UMTS,	U3GFL_STUB_WAIT },	// XXX
+	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_V740 },		U3GSP_HSDPA,	U3GFL_STUB_WAIT },
+	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_X950D },		U3GSP_HSUPA,	U3GFL_STUB_WAIT },
+	{{ USB_VENDOR_NOVATEL, USB_PRODUCT_NOVATEL_XU870 },		U3GSP_HSDPA,	U3GFL_STUB_WAIT },
+	{{ USB_VENDOR_DELL,    USB_PRODUCT_DELL_U740 },			U3GSP_HSDPA,	U3GFL_STUB_WAIT },
+	/* OEM: Merlin */
+	{{ USB_VENDOR_MERLIN, USB_PRODUCT_MERLIN_V620 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	/* OEM: Sierra Wireless: */
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AIRCARD580 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AIRCARD595 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC595U },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC597E },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_C597 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC880 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC880E },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC880U },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC881 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC881E },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC881U },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_EM5625 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5720 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5720_2 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5725 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MINI5725 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AIRCARD875 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8755 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8755_2 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8755_3 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8765 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC875U },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8775_2 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8780 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
+	{{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8781 },		U3GSP_UMTS,	U3GFL_NONE },		// XXX
 };
 #define u3g_lookup(v, p) ((const struct u3g_dev_type_s *)usb_lookup(u3g_devs, v, p))
 
-#ifdef U3G_DEBUG
-static void
-u3g_intr(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
-{
-	struct u3g_softc *sc = (struct u3g_softc *)priv;
-	device_printf(sc->sc_dev, "Interrupt callback\n");
-}
-#endif
-
 static int
 u3g_match(device_t self)
 {
 	struct usb_attach_arg *uaa = device_get_ivars(self);
-	usb_interface_descriptor_t *id;
 	const struct u3g_dev_type_s *u3g_dev_type;
 
-	if (uaa->vendor == USB_VENDOR_HUAWEI) {
-		if (uaa->iface) {
-			/* We attach to the interface instead of the device as
-			 * some devices have a built-in SD card reader on the
-			 * second interface. If the interface class of the
-			 * first interface is no longer mass storage it has
-			 * changed appearance and we should attach it.
-			 */
-			id = usbd_get_interface_descriptor(uaa->iface);
-			if (id && id->bInterfaceClass == UICLASS_VENDOR)
-				return (UMATCH_VENDOR_PRODUCT_CONF_IFACE);
-		}
+	if (!uaa->iface)
 		return UMATCH_NONE;
-	}
 
 	u3g_dev_type = u3g_lookup(uaa->vendor, uaa->product);
-	if (u3g_dev_type)
-		return UMATCH_VENDOR_PRODUCT;
+	if (!u3g_dev_type)
+		return UMATCH_NONE;
 
-	return UMATCH_NONE;
+	if (u3g_dev_type->flags&U3GFL_HUAWEI_INIT) {
+		/* If the interface class of the first interface is no longer
+		 * mass storage the card has changed to modem (see u3g_attach()
+		 * below).
+		 */
+		usb_interface_descriptor_t *id;
+		id = usbd_get_interface_descriptor(uaa->iface);
+		if (!id || id->bInterfaceClass == UICLASS_MASS)
+			return UMATCH_NONE;
+	}
+
+	return UMATCH_VENDOR_PRODUCT_CONF_IFACE;
 }
 
 static int
@@ -168,120 +197,105 @@ u3g_attach(device_t self)
 {
 	struct u3g_softc *sc = device_get_softc(self);
 	struct usb_attach_arg *uaa = device_get_ivars(self);
+	const struct u3g_dev_type_s *u3g_dev_type;
 	usbd_device_handle dev = uaa->device;
-	usbd_interface_handle iface;
 	usb_interface_descriptor_t *id;
 	usb_endpoint_descriptor_t *ed;
-	usbd_status error;
 	int i, n; 
 	usb_config_descriptor_t *cd;
-	struct ucom_softc *ucom = NULL;
 	char devnamefmt[32];
 
-	sc->sc_dev = self;
-#ifdef U3G_DEBUG
-	sc->sc_intr_number = -1;
-	sc->sc_intr_pipe = NULL;
-#endif
-	/* Move the device into the configured state. */
-	error = usbd_set_config_index(dev, U3G_CONFIG_INDEX, 1);
-	if (error) {
-		device_printf(self, "failed to set configuration: %s\n",
-			      usbd_errstr(error));
-		goto bad;
-	}
-
 	/* get the config descriptor */
 	cd = usbd_get_config_descriptor(dev);
-
 	if (cd == NULL) {
 		device_printf(self, "failed to get configuration descriptor\n");
-		goto bad;
+		return ENXIO;
 	}
 
+	sc->sc_dev = self;
 	sc->sc_udev = dev;
-	sc->numports = (cd->bNumInterface <= U3G_MAXPORTS)?cd->bNumInterface:U3G_MAXPORTS;
-	for ( i = 0; i < sc->numports; i++ ) {
-		ucom = &sc->sc_ucom[i];
-
-		ucom->sc_dev = self;
-		ucom->sc_udev = dev;
-		error = usbd_device2interface_handle(dev, i, &iface);
-		if (error) {
-			device_printf(ucom->sc_dev,
-				"failed to get interface, err=%s\n",
-			usbd_errstr(error));
-			ucom->sc_dying = 1;
-			goto bad;
+
+	u3g_dev_type = u3g_lookup(uaa->vendor, uaa->product);
+	sc->sc_flags = u3g_dev_type->flags;
+	sc->sc_speed = u3g_dev_type->speed;
+
+	sprintf(devnamefmt,"U%d.%%d", device_get_unit(self));
+	int portno = 0;
+	for (i = 0; i < uaa->nifaces && portno < U3G_MAXPORTS; i++) {
+		if (uaa->ifaces[i] == NULL)
+			continue;
+
+		id = usbd_get_interface_descriptor(uaa->ifaces[i]);
+		if (id && id->bInterfaceClass == UICLASS_MASS) {
+			/* We attach to the interface instead of the device as
+			 * some devices have a built-in SD card reader.
+			 * Claim the first umass device (cdX) as it contains
+			 * only Windows drivers anyway (CD-ROM), hiding it.
+			 */
+#ifndef U3G_DEBUG
+			if (!bootverbose)
+				if (uaa->vendor == USB_VENDOR_HUAWEI)
+					if (id->bInterfaceNumber == 2)
+						uaa->ifaces[i] = NULL;
+#endif
+			continue;
 		}
-		id = usbd_get_interface_descriptor(iface);
-		ucom->sc_iface = iface;
 
-		ucom->sc_bulkin_no = ucom->sc_bulkout_no = -1;
+		int bulkin_no = -1, bulkout_no = -1;
 		for (n = 0; n < id->bNumEndpoints; n++) {
-			ed = usbd_interface2endpoint_descriptor(iface, n);
-			if (ed == NULL) {
-				device_printf(ucom->sc_dev,
-					      "could not read endpoint descriptor\n");
-				goto bad;
-			}
+			ed = usbd_interface2endpoint_descriptor(uaa->ifaces[i], n);
+			if (ed == NULL)
+				continue;
 			if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN
 			    && UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK)
-				ucom->sc_bulkin_no = ed->bEndpointAddress;
+				bulkin_no = ed->bEndpointAddress;
 			else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT
 				 && UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK)
-				ucom->sc_bulkout_no = ed->bEndpointAddress;
-		}
-		if (ucom->sc_bulkin_no == -1 || ucom->sc_bulkout_no == -1) {
-			device_printf(ucom->sc_dev, "missing endpoint\n");
-			goto bad;
-		}
-		ucom->sc_parent = sc;
-		ucom->sc_ibufsize = U3G_BUFSIZ;
-		ucom->sc_obufsize = U3G_BUFSIZ;
-		ucom->sc_ibufsizepad = U3G_BUFSIZ;
-		ucom->sc_opkthdrlen = 0;
-
-		ucom->sc_callback = &u3g_callback;
-
-		sprintf(devnamefmt,"U%d.%%d", device_get_unit(self));
-		DPRINTF(("u3g: in=0x%x out=0x%x, devname=%s\n",
-			 ucom->sc_bulkin_no, ucom->sc_bulkout_no, devnamefmt));
+				bulkout_no = ed->bEndpointAddress;
+
+			/* If we have found a pair of bulk-in/-out endpoints
+			 * create a serial port for it. Note: We assume that
+			 * the bulk-in and bulk-out endpoints appear in pairs.
+			 */
+			if (bulkin_no != -1 && bulkout_no != -1) {
+				struct ucom_softc *ucom = &sc->sc_ucom[portno];
+
+				ucom->sc_dev = self;
+				ucom->sc_udev = dev;
+				ucom->sc_iface = uaa->ifaces[i];
+				ucom->sc_bulkin_no = bulkin_no;
+				ucom->sc_ibufsize = U3G_BUFSIZ;
+				ucom->sc_ibufsizepad = U3G_BUFSIZ;	// XXX What's this?
+				ucom->sc_bulkout_no = bulkout_no;
+				ucom->sc_obufsize = U3G_BUFSIZ;
+				ucom->sc_opkthdrlen = 0;
+
+				ucom->sc_callback = &u3g_callback;
+				ucom->sc_parent = sc;
+				ucom->sc_portno = portno;
+
+				DPRINTF("port=%d iface=%d in=0x%x out=0x%x\n",
+					 portno, i,
+					 ucom->sc_bulkin_no,
+					 ucom->sc_bulkout_no);
 #if __FreeBSD_version < 800000
-		ucom_attach_tty(ucom, TS_CALLOUT, devnamefmt, i);
+				ucom_attach_tty(ucom, TS_CALLOUT, devnamefmt, portno);
 #else
-		ucom_attach_tty(ucom, devnamefmt, i);
+				ucom_attach_tty(ucom, devnamefmt, portno);
 #endif
-	}
-#ifdef U3G_DEBUG
-	if (sc->sc_intr_number != -1 && sc->sc_intr_pipe == NULL) {
-		sc->sc_intr_buf = malloc(sc->sc_isize, M_USBDEV, M_WAITOK);
-		error = usbd_open_pipe_intr(sc->sc_intr_iface,
-					    sc->sc_intr_number,
-					    USBD_SHORT_XFER_OK,
-					    &sc->sc_intr_pipe,
-					    sc,
-					    sc->sc_intr_buf,
-					    sc->sc_isize,
-					    u3g_intr,
-					    100);
-		if (error) {
-			device_printf(self,
-				      "cannot open interrupt pipe (addr %d)\n",
-				      sc->sc_intr_number);
-			goto bad;
+
+				uaa->ifaces[i] = NULL;
+				portno++;
+				bulkin_no = bulkout_no = -1;
+			}
 		}
+
 	}
-#endif
-	device_printf(self, "configured %d serial ports (/dev/cuaU%d.X)\n",
-		      sc->numports, device_get_unit(self));
+	sc->sc_numports = portno;
 
+	device_printf(self, "configured %d serial ports (%s)\n",
+		      sc->sc_numports, devnamefmt);
 	return 0;
-
-bad:
-	DPRINTF(("u3g_attach: ATTACH ERROR\n"));
-	ucom->sc_dying = 1;
-	return ENXIO;
 }
 
 static int
@@ -291,39 +305,98 @@ u3g_detach(device_t self)
 	int rv = 0;
 	int i;
 
-	DPRINTF(("u3g_detach: sc=%p\n", sc));
-
-	for (i = 0; i < sc->numports; i++) {
-		if(sc->sc_ucom[i].sc_udev) {
-			sc->sc_ucom[i].sc_dying = 1;
-			rv = ucom_detach(&sc->sc_ucom[i]);
-			if(rv != 0) {
-				device_printf(self, "Can't deallocat port %d\n", i);
-				return rv;
-			}
+	for (i = 0; i < sc->sc_numports; i++) {
+		sc->sc_ucom[i].sc_dying = 1;
+		rv = ucom_detach(&sc->sc_ucom[i]);
+		if (rv != 0) {
+			device_printf(self, "ucom_detach(U%d.%d\n", device_get_unit(self), i);
+			return rv;
 		}
 	}
 
+	return 0;
+}
+
+static int
+u3g_open(void *addr, int portno)
+{
+#if __FreeBSD_version < 800000
+	/* Supply generous buffering for these cards to avoid disappointments
+	 * when setting the speed incorrectly. Only do this for the first port
+	 * assuming that the rest of the ports are used for diagnostics only
+	 * anyway.
+	 * Note: We abuse the fact that ucom sets the speed through
+	 * ispeed/ospeed, not through ispeedwat/ospeedwat.
+	 */
+	if (portno == 0) {
+		struct u3g_softc *sc = addr;
+		struct ucom_softc *ucom = &sc->sc_ucom[portno];
+		struct tty *tp = ucom->sc_tty;
 #ifdef U3G_DEBUG
-	if (sc->sc_intr_pipe != NULL) {
-		int err = usbd_abort_pipe(sc->sc_intr_pipe);
-		if (err)
-			device_printf(self,
-				"abort interrupt pipe failed: %s\n",
-				usbd_errstr(err));
-		err = usbd_close_pipe(sc->sc_intr_pipe);
-		if (err)
-			device_printf(self,
-				      "close interrupt pipe failed: %s\n",
-				      usbd_errstr(err));
-		free(sc->sc_intr_buf, M_USBDEV);
-		sc->sc_intr_pipe = NULL;
+		device_t self = sc->sc_dev;
+#endif
+
+		if (sc->sc_speed&U3GSP_HSPA) {
+			tp->t_ispeedwat = 7200000;
+			tp->t_ospeedwat = 384000;
+		} else if (sc->sc_speed&U3GSP_HSUPA) {
+			tp->t_ispeedwat = 1200000;
+			tp->t_ospeedwat = 384000;
+		} else if (sc->sc_speed&U3GSP_HSDPA) {
+			tp->t_ispeedwat = 1200000;
+			tp->t_ospeedwat = 384000;
+		} else if (sc->sc_speed&U3GSP_UMTS) {
+			tp->t_ispeedwat = 384000;
+			tp->t_ospeedwat = 64000;
+		} else if (sc->sc_speed&U3GSP_EDGE) {
+			tp->t_ispeedwat = 384000;
+			tp->t_ospeedwat = 64000;
+		} else {
+			tp->t_ispeedwat = 64000;
+			tp->t_ospeedwat = 64000;
+		}
+
+		/* Avoid excessive buffer sizes. On modern fast machines this is
+		 * not needed.
+		 * XXX The values here should be checked. Lower them and see
+		 * whether 'lost chars' messages appear.
+		 */
+		if (tp->t_ispeedwat > 384000)
+		    tp->t_ispeedwat = 384000;
+		if (tp->t_ospeedwat > 384000)
+		    tp->t_ospeedwat = 384000;
+
+		DPRINTF("ispeedwat = %d, ospeedwat = %d\n",
+			tp->t_ispeedwat, tp->t_ospeedwat);
+		ttsetwater(tp);
 	}
 #endif
 
 	return 0;
 }
 
+static void
+u3g_close(void *addr, int portno)
+{
+#if __FreeBSD_version < 800000
+	if (portno == 0) {	/* see u3g_open() */
+		/* Reduce the buffers allocated above again */
+		struct u3g_softc *sc = addr;
+		struct ucom_softc *ucom = &sc->sc_ucom[portno];
+		struct tty *tp = ucom->sc_tty;
+#ifdef U3G_DEBUG
+		device_t self = sc->sc_dev;
+#endif
+
+		tp->t_ispeedwat = (speed_t)-1;
+		tp->t_ospeedwat = (speed_t)-1;
+
+		DPRINTF("ispeedwat = default, ospeedwat = default\n");
+		ttsetwater(tp);
+	}
+#endif
+}	
+
 static device_method_t u3g_methods[] = {
 	/* Device interface */
 	DEVMETHOD(device_probe, u3g_match),
@@ -365,32 +438,29 @@ static int
 u3gstub_match(device_t self)
 {
 	struct usb_attach_arg *uaa = device_get_ivars(self);
-	usb_device_descriptor_t *dd = usbd_get_device_descriptor(uaa->device);
+	const struct u3g_dev_type_s *u3g_dev_type;
 	usb_interface_descriptor_t *id;
 
-	/* These are 3G modem devices (E220, Mobile, etc.) with auto-install
-	 * flash disks for Windows/MacOSX through the first interface.
+	/* This stub handles 3G modem devices (E220, Mobile, etc.) with
+	 * auto-install flash disks for Windows/MacOSX on the first interface.
+	 * After some command or some delay they change appearance to a modem.
 	 */
-	if (uaa->vendor == USB_VENDOR_HUAWEI) {
-		/* The Huawei device presents itself as a umass device with
-		 * Windows drivers on it. After installation of the driver, it
-		 * reinits into a 3G serial device.
-		 */
-		if (uaa->iface) {
-			id = usbd_get_interface_descriptor(uaa->iface);
-			if (id && id->bInterfaceNumber == 0 && id->bInterfaceClass == UICLASS_MASS) {
-				u3gstub_huawei_init(uaa->device);
-				return (UMATCH_VENDOR_PRODUCT_CONF_IFACE);
-			}
-		}
-	}
 
-	if (UGETW(dd->idVendor) == USB_VENDOR_QUALCOMMINC
-	    || UGETW(dd->idVendor) == USB_VENDOR_NOVATEL) {
-		/* Device by these vendors will automatically reappear as a
-		 * ucom device if ignored (or if sent an eject command).
+	if (!uaa->iface)
+		return UMATCH_NONE;
+
+	u3g_dev_type = u3g_lookup(uaa->vendor, uaa->product);
+	if (!u3g_dev_type)
+		return UMATCH_NONE;
+
+	if (u3g_dev_type->flags&U3GFL_HUAWEI_INIT
+	    || u3g_dev_type->flags&U3GFL_STUB_WAIT) {
+		/* We assume that if the first interface is still a mass
+		 * storage device the device has not yet changed appearance.
 		 */
-		return UMATCH_VENDOR_PRODUCT;
+		id = usbd_get_interface_descriptor(uaa->iface);
+		if (id && id->bInterfaceNumber == 0 && id->bInterfaceClass == UICLASS_MASS)
+			return UMATCH_VENDOR_PRODUCT;
 	}
 
 	return UMATCH_NONE;
@@ -399,11 +469,28 @@ u3gstub_match(device_t self)
 static int
 u3gstub_attach(device_t self)
 {
-#if 0
-	if (!bootverbose)
+	struct usb_attach_arg *uaa = device_get_ivars(self);
+	const struct u3g_dev_type_s *u3g_dev_type;
+	int i;
+#ifndef U3G_DEBUG
+	if (!bootverbose)				// hide the stub attachment
 		device_quiet(self);
 #endif
 
+	if (uaa->iface)
+		for (i = 0; i < uaa->nifaces; i++)
+			uaa->ifaces[i] = NULL;		// claim all interfaces
+
+	u3g_dev_type = u3g_lookup(uaa->vendor, uaa->product);
+	if (u3g_dev_type->flags&U3GFL_HUAWEI_INIT) {
+		/* XXX Should we delay the kick?
+		 */
+		DPRINTF("changing Huawei modem to modem mode\n");
+		u3gstub_huawei_init(uaa->device);
+	} else if (u3g_dev_type->flags&U3GFL_STUB_WAIT) {
+		/* nop  */
+	}
+
 	return 0;
 }
 

Modified: head/sys/dev/usb/ubsa.c
==============================================================================
--- head/sys/dev/usb/ubsa.c	Wed Oct 15 20:44:00 2008	(r183924)
+++ head/sys/dev/usb/ubsa.c	Wed Oct 15 21:25:11 2008	(r183925)
@@ -226,52 +226,6 @@ static const struct ubsa_product {
 	{ USB_VENDOR_GOHUBS, USB_PRODUCT_GOHUBS_GOCOM232 },
 	/* Peracom */
 	{ USB_VENDOR_PERACOM, USB_PRODUCT_PERACOM_SERIAL1 },
-	/* Merlin */
-	{ USB_VENDOR_MERLIN, USB_PRODUCT_MERLIN_V620 },
-	/* Sierra Wireless AirCard 580 */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AIRCARD580 },
-	/* Sierra Wireless AirCard 595 */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AIRCARD595 },
-	/* Sierra Wireless AirCard 595U */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC595U },
-	/* Sierra Wireless AirCard 597E */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC597E },
-	/* Sierra Wireless Compass 597 */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_C597 },
-	/* Sierra Wireless AirCard 880 */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC880 },
-	/* Sierra Wireless AirCard 880E */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC880E },
-	/* Sierra Wireless AirCard 880U */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC880U },
-	/* Sierra Wireless AirCard 881 */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC881 },
-	/* Sierra Wireless AirCard 881E */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC881E },
-	/* Sierra Wireless AirCard 881U */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC881U },
-	/* Sierra Wireless EM5625 */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_EM5625 },
-	/* Sierra Wireless MC5720 */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5720 },
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5720_2 },
-	/* Sierra Wireless MC5725 */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC5725 },
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MINI5725 },
-	/* Sierra Wireless MC8755 */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AIRCARD875 },
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8755 },
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8755_2 },
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8755_3 },
-	/* Sierra Wireless MC8765 */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8765 },
-	/* Sierra Wireless MC8775 */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_AC875U },
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8775_2 },
-	/* Sierra Wireless MC8780 */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8780 },
-	/* Sierra Wireless MC8781 */
-	{ USB_VENDOR_SIERRA, USB_PRODUCT_SIERRA_MC8781 },
 	{ 0, 0 }
 };
 

Modified: head/sys/dev/usb/usbdevs
==============================================================================
--- head/sys/dev/usb/usbdevs	Wed Oct 15 20:44:00 2008	(r183924)
+++ head/sys/dev/usb/usbdevs	Wed Oct 15 21:25:11 2008	(r183925)
@@ -1872,6 +1872,7 @@ product OPTION GT3G		0x6000	GlobeTrotter
 product OPTION GT3GQUAD		0x6300	GlobeTrotter 3G QUAD datacard
 product OPTION GT3GPLUS		0x6600	GlobeTrotter 3G+ datacard
 product OPTION GTMAX36		0x6701	GlobeTrotter Max 3.6 Modem
+product OPTION GTMAXHSUPA	0x7001	GlobeTrotter HSUPA
 
 /* OQO */
 product OQO WIFI01		0x0002	model 01 WiFi interface
From n_hibma at FreeBSD.org  Wed Oct 15 21:47:01 2008
From: n_hibma at FreeBSD.org (Nick Hibma)
Date: Wed Oct 15 21:47:07 2008
Subject: svn commit: r183926 - head/share/man/man4
Message-ID: <200810152147.m9FLl1pl044118@svn.freebsd.org>

Author: n_hibma
Date: Wed Oct 15 21:47:01 2008
New Revision: 183926
URL: http://svn.freebsd.org/changeset/base/183926

Log:
  Comment on the umass CD ROM devices in the UMTS modems.

Modified:
  head/share/man/man4/u3g.4

Modified: head/share/man/man4/u3g.4
==============================================================================
--- head/share/man/man4/u3g.4	Wed Oct 15 21:25:11 2008	(r183925)
+++ head/share/man/man4/u3g.4	Wed Oct 15 21:47:01 2008	(r183926)
@@ -73,6 +73,8 @@ Huawei E220 (E270?)
 Huawei Mobile
 .It
 Novatal MC950D
+.It
+Sierra cards
 .El
 (See /sys/dev/u3g.c for the complete list of supported cards for each vendor
 mentioned above).
@@ -80,6 +82,12 @@ mentioned above).
 The supported 3G cards provide the necessary modem port for ppp,
 pppd, or mpd connections as well as extra ports (depending on the specific
 device) to provide other functions (diagnostic port, SIM toolkit port)
+.Pp
+In some of these devices a mass storage device supported by the 
+.Xr umass 4
+driver is present which contains Windows and Mac OSX drivers. This device is
+hidden, unless the machine was booted in verbose (see
+.Xr boot 8 ).
 .Sh SEE ALSO
 .Xr tty 4 ,
 .Xr ucom 4 ,
@@ -97,5 +105,7 @@ in September 2008.
 The
 .Nm
 driver was written by
-.An Andrea Guzzo Aq aguzzo@anywi.com .
+.An Andrea Guzzo Aq aguzzo@anywi.com
+and
+.An Nick Hibma Aq n_hibma@freebsd.org .
 Hardware for testing provided by AnyWi Technologies, Leiden, NL.
From davidxu at FreeBSD.org  Thu Oct 16 04:17:18 2008
From: davidxu at FreeBSD.org (David Xu)
Date: Thu Oct 16 04:17:29 2008
Subject: svn commit: r183929 - head/sys/kern
Message-ID: <200810160417.m9G4HHAM051248@svn.freebsd.org>

Author: davidxu
Date: Thu Oct 16 04:17:17 2008
New Revision: 183929
URL: http://svn.freebsd.org/changeset/base/183929

Log:
  Restore code wrongly removed in SVN revision 173004, it causes threaded
  process to be stuck in execv().
  
  Noticed by: delphij

Modified:
  head/sys/kern/kern_thread.c

Modified: head/sys/kern/kern_thread.c
==============================================================================
--- head/sys/kern/kern_thread.c	Thu Oct 16 01:46:01 2008	(r183928)
+++ head/sys/kern/kern_thread.c	Thu Oct 16 04:17:17 2008	(r183929)
@@ -572,8 +572,16 @@ thread_single(int mode)
 						    sleepq_abort(td2, EINTR);
 					break;
 				case SINGLE_BOUNDARY:
+					if (TD_IS_SUSPENDED(td2) &&
+					    !(td2->td_flags & TDF_BOUNDARY))
+						wakeup_swapper |=
+						    thread_unsuspend_one(td2);
+					if (TD_ON_SLEEPQ(td2) &&
+					    (td2->td_flags & TDF_SINTR))
+						wakeup_swapper |=
+						    sleepq_abort(td2, ERESTART);
 					break;
-				default:	
+				default:
 					if (TD_IS_SUSPENDED(td2)) {
 						thread_unlock(td2);
 						continue;
From zec at FreeBSD.org  Thu Oct 16 12:31:04 2008
From: zec at FreeBSD.org (Marko Zec)
Date: Thu Oct 16 12:31:09 2008
Subject: svn commit: r183954 - head/sys/netinet
Message-ID: <200810161231.m9GCV30h061685@svn.freebsd.org>

Author: zec
Date: Thu Oct 16 12:31:03 2008
New Revision: 183954
URL: http://svn.freebsd.org/changeset/base/183954

Log:
  Remove a useless global static variable.
  
  Approved by:	bz (ad-hoc mentor)

Modified:
  head/sys/netinet/if_ether.c

Modified: head/sys/netinet/if_ether.c
==============================================================================
--- head/sys/netinet/if_ether.c	Thu Oct 16 11:02:05 2008	(r183953)
+++ head/sys/netinet/if_ether.c	Thu Oct 16 12:31:03 2008	(r183954)
@@ -98,7 +98,6 @@ struct llinfo_arp {
 };
 
 static struct	ifqueue arpintrq;
-static int	arp_allocated;
 
 static int	arp_maxtries = 5;
 static int	useloopback = 1; /* use loopback interface for local traffic */
@@ -221,7 +220,6 @@ arp_rtrequest(int req, struct rtentry *r
 			log(LOG_DEBUG, "%s: malloc failed\n", __func__);
 			break;
 		}
-		arp_allocated++;
 		/*
 		 * We are storing a route entry outside of radix tree. So,
 		 * it can be found and accessed by other means than radix
From attilio at FreeBSD.org  Thu Oct 16 12:42:57 2008
From: attilio at FreeBSD.org (Attilio Rao)
Date: Thu Oct 16 12:43:02 2008
Subject: svn commit: r183955 - head/sys/kern
Message-ID: <200810161242.m9GCgu5w061909@svn.freebsd.org>

Author: attilio
Date: Thu Oct 16 12:42:56 2008
New Revision: 183955
URL: http://svn.freebsd.org/changeset/base/183955

Log:
  - Fix a race in witness_checkorder() where, between the PCPU_GET() and
    PCPU_PTR() curthread can migrate on another CPU and get incorrect
    results.
  - Fix a similar race into witness_warn().
  - Fix the interlock's checks bypassing by correctly using the appropriate
    children even when the lock_list chunk to be explored is not the first
    one.
  - Allow witness_warn() to work with spinlocks too.
  
  Bugs found by:	tegge
  Submitted by:	jhb, tegge
  Tested by:	Giovanni Trematerra 

Modified:
  head/sys/kern/subr_witness.c

Modified: head/sys/kern/subr_witness.c
==============================================================================
--- head/sys/kern/subr_witness.c	Thu Oct 16 12:31:03 2008	(r183954)
+++ head/sys/kern/subr_witness.c	Thu Oct 16 12:42:56 2008	(r183955)
@@ -103,6 +103,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1015,7 +1016,7 @@ void
 witness_checkorder(struct lock_object *lock, int flags, const char *file,
     int line, struct lock_object *interlock)
 {
-	struct lock_list_entry **lock_list, *lle;
+	struct lock_list_entry *lock_list, *lle;
 	struct lock_instance *lock1, *lock2, *plock;
 	struct lock_class *class;
 	struct witness *w, *w1;
@@ -1046,35 +1047,34 @@ witness_checkorder(struct lock_object *l
 		 * If this is the first lock acquired then just return as
 		 * no order checking is needed.
 		 */
-		if (td->td_sleeplocks == NULL)
+		lock_list = td->td_sleeplocks;
+		if (lock_list == NULL || lock_list->ll_count == 0)
 			return;
-		lock_list = &td->td_sleeplocks;
 	} else {
 
 		/*
 		 * If this is the first lock, just return as no order
-		 * checking is needed.  We check this in both if clauses
-		 * here as unifying the check would require us to use a
-		 * critical section to ensure we don't migrate while doing
-		 * the check.  Note that if this is not the first lock, we
-		 * are already in a critical section and are safe for the
-		 * rest of the check.
+		 * checking is needed.  Avoid problems with thread
+		 * migration pinning the thread while checking if
+		 * spinlocks are held.  If at least one spinlock is held
+		 * the thread is in a safe path and it is allowed to
+		 * unpin it.
 		 */
-		if (PCPU_GET(spinlocks) == NULL)
+		sched_pin();
+		lock_list = PCPU_GET(spinlocks);
+		if (lock_list == NULL || lock_list->ll_count == 0) {
+			sched_unpin();
 			return;
-		lock_list = PCPU_PTR(spinlocks);
+		}
+		sched_unpin();
 	}
 
-	/* Empty list? */
-	if ((*lock_list)->ll_count == 0)
-		return;
-
 	/*
 	 * Check to see if we are recursing on a lock we already own.  If
 	 * so, make sure that we don't mismatch exclusive and shared lock
 	 * acquires.
 	 */
-	lock1 = find_instance(*lock_list, lock);
+	lock1 = find_instance(lock_list, lock);
 	if (lock1 != NULL) {
 		if ((lock1->li_flags & LI_EXCLUSIVE) != 0 &&
 		    (flags & LOP_EXCLUSIVE) == 0) {
@@ -1098,17 +1098,22 @@ witness_checkorder(struct lock_object *l
 	/*
 	 * Find the previously acquired lock, but ignore interlocks.
 	 */
-	plock = &(*lock_list)->ll_children[(*lock_list)->ll_count - 1];
+	plock = &lock_list->ll_children[lock_list->ll_count - 1];
 	if (interlock != NULL && plock->li_lock == interlock) {
-		if ((*lock_list)->ll_count == 1) {
+		if (lock_list->ll_count > 1)
+			plock =
+			    &lock_list->ll_children[lock_list->ll_count - 2];
+		else {
+			lle = lock_list->ll_next;
 
 			/*
 			 * The interlock is the only lock we hold, so
-			 * nothing to do.
+			 * simply return.
 			 */
-			return;
+			if (lle == NULL)
+				return;
+			plock = &lle->ll_children[lle->ll_count - 1];
 		}
-		plock = &(*lock_list)->ll_children[(*lock_list)->ll_count - 2];
 	}
 	
 	/*
@@ -1154,7 +1159,7 @@ witness_checkorder(struct lock_object *l
 	if (isitmychild(w1, w))
 		goto out;
 
-	for (j = 0, lle = *lock_list; lle != NULL; lle = lle->ll_next) {
+	for (j = 0, lle = lock_list; lle != NULL; lle = lle->ll_next) {
 		for (i = lle->ll_count - 1; i >= 0; i--, j++) {
 
 			MPASS(j < WITNESS_COUNT);
@@ -1582,7 +1587,7 @@ witness_thread_exit(struct thread *td)
 int
 witness_warn(int flags, struct lock_object *lock, const char *fmt, ...)
 {
-	struct lock_list_entry **lock_list, *lle;
+	struct lock_list_entry *lock_list, *lle;
 	struct lock_instance *lock1;
 	struct thread *td;
 	va_list ap;
@@ -1615,17 +1620,33 @@ witness_warn(int flags, struct lock_obje
 			n++;
 			witness_list_lock(lock1);
 		}
-	if (PCPU_GET(spinlocks) != NULL) {
-		lock_list = PCPU_PTR(spinlocks);
+
+	/*
+	 * Pin the thread in order to avoid problems with thread migration.
+	 * Once that all verifies are passed about spinlocks ownership,
+	 * the thread is in a safe path and it can be unpinned.
+	 */
+	sched_pin();
+	lock_list = PCPU_GET(spinlocks);
+	if (lock_list != NULL) {
 
 		/* Empty list? */
-		if ((*lock_list)->ll_count == 0)
+		if (lock_list->ll_count == 0) {
+			sched_unpin();
 			return (n);
+		}
+		sched_unpin();
 
 		/*
-		 * Since we already hold a spinlock preemption is
-		 * already blocked.
+		 * We should only have one spinlock and as long as
+		 * the flags cannot match for this locks class,
+		 * check if the first spinlock is the one curthread
+		 * should hold.
 		 */
+		lock1 = &lock_list->ll_children[lock_list->ll_count - 1];
+		if (lock1->li_lock == lock)
+			return (n);
+
 		if (n == 0) {
 			va_start(ap, fmt);
 			vprintf(fmt, ap);
@@ -1635,8 +1656,9 @@ witness_warn(int flags, struct lock_obje
 				printf(" non-sleepable");
 			printf(" locks held:\n");
 		}
-		n += witness_list_locks(PCPU_PTR(spinlocks));
-	}
+		n += witness_list_locks(&lock_list);
+	} else
+		sched_unpin();
 	if (flags & WARN_PANIC && n)
 		panic("%s", __func__);
 	else
From obrien at FreeBSD.org  Thu Oct 16 18:09:28 2008
From: obrien at FreeBSD.org (David E. O'Brien)
Date: Thu Oct 16 18:09:34 2008
Subject: svn commit: r183957 - in head/gnu/usr.bin/gdb/arch: amd64 i386
Message-ID: <200810161809.m9GI9R2D067407@svn.freebsd.org>

Author: obrien
Date: Thu Oct 16 18:09:27 2008
New Revision: 183957
URL: http://svn.freebsd.org/changeset/base/183957

Log:
  Document what the sed trick is for.
  Remove an embedded , and use same style for both files.

Modified:
  head/gnu/usr.bin/gdb/arch/amd64/Makefile
  head/gnu/usr.bin/gdb/arch/i386/Makefile

Modified: head/gnu/usr.bin/gdb/arch/amd64/Makefile
==============================================================================
--- head/gnu/usr.bin/gdb/arch/amd64/Makefile	Thu Oct 16 17:11:06 2008	(r183956)
+++ head/gnu/usr.bin/gdb/arch/amd64/Makefile	Thu Oct 16 18:09:27 2008	(r183957)
@@ -7,7 +7,7 @@ LIBSRCS+= amd64-nat.c amd64bsd-nat.c amd
 .endif
 LIBSRCS+= solib.c solib-svr4.c
 LIBSRCS+= amd64-tdep.c amd64fbsd-tdep.c i386-tdep.c i386bsd-tdep.c \
-	i386fbsd-tdep-fixed.c	i387-tdep.c
+	i386fbsd-tdep-fixed.c i387-tdep.c
 
 nm.h:
 	echo '#include "i386/nm-fbsd64.h"' > ${.TARGET}
@@ -18,7 +18,7 @@ tm.h:
 xm.h:
 	echo '#include "i386/xm-i386.h"' > ${.TARGET}
 
+# Fix source static/extern mismatch nits that GCC 4.2 warns about.
+CLEANFILES+= i386fbsd-tdep-fixed.c
 i386fbsd-tdep-fixed.c: i386fbsd-tdep.c
 	sed -e '48s/^static //' ${.ALLSRC} > ${.TARGET}
-
-CLEANFILES+= i386fbsd-tdep-fixed.c

Modified: head/gnu/usr.bin/gdb/arch/i386/Makefile
==============================================================================
--- head/gnu/usr.bin/gdb/arch/i386/Makefile	Thu Oct 16 17:11:06 2008	(r183956)
+++ head/gnu/usr.bin/gdb/arch/i386/Makefile	Thu Oct 16 18:09:27 2008	(r183957)
@@ -17,6 +17,7 @@ tm.h:
 xm.h:
 	echo '#include "i386/xm-i386.h"' > ${.TARGET}
 
+# Fix source static/extern mismatch nits that GCC 4.2 warns about.
+CLEANFILES += i386fbsd-tdep-fixed.c
 i386fbsd-tdep-fixed.c: i386fbsd-tdep.c
 	sed -e '48s/^static\ //' ${.ALLSRC} > ${.TARGET}
-CLEANFILES += i386fbsd-tdep-fixed.c
From raj at FreeBSD.org  Thu Oct 16 19:06:25 2008
From: raj at FreeBSD.org (Rafal Jaworowski)
Date: Thu Oct 16 19:06:31 2008
Subject: svn commit: r183958 - head/sys/arm/arm
Message-ID: <200810161906.m9GJ6OXG068433@svn.freebsd.org>

Author: raj
Date: Thu Oct 16 19:06:24 2008
New Revision: 183958
URL: http://svn.freebsd.org/changeset/base/183958

Log:
  Eliminate flushing of L2 cache in ARM context switch routines.
  
  With VIPT L2 cache such syncing not only is redundant, but also a performance
  penalty.
  
  Pointed out by:	cognet

Modified:
  head/sys/arm/arm/swtch.S

Modified: head/sys/arm/arm/swtch.S
==============================================================================
--- head/sys/arm/arm/swtch.S	Thu Oct 16 18:09:27 2008	(r183957)
+++ head/sys/arm/arm/swtch.S	Thu Oct 16 19:06:24 2008	(r183958)
@@ -143,8 +143,6 @@ ENTRY(cpu_throw)
 	ldr	r9, .Lcpufuncs
 	mov	lr, pc
 	ldr	pc, [r9, #CF_IDCACHE_WBINV_ALL]
-	mov	lr, pc
-	ldr	pc, [r9, #CF_L2CACHE_WBINV_ALL]
 	ldr	r0, [r7, #(PCB_PL1VEC)]
 	ldr	r1, [r7, #(PCB_DACR)]
 	/*
@@ -174,8 +172,6 @@ ENTRY(cpu_throw)
 	movne	r1, #4
 	movne	lr, pc
 	ldrne	pc, [r9, #CF_DCACHE_WB_RANGE]
-	movne	lr, pc
-	ldrne	pc, [r9, #CF_L2CACHE_WB_RANGE]
 #endif /* PMAP_INCLUDE_PTE_SYNC */
 
 	/*
@@ -332,8 +328,6 @@ ENTRY(cpu_switch)
 	ldr	r1, .Lcpufuncs
 	mov	lr, pc
 	ldr	pc, [r1, #CF_IDCACHE_WBINV_ALL]
-	mov	lr, pc
-	ldr	pc, [r1, #CF_L2CACHE_WBINV_ALL]
 .Lcs_cache_purge_skipped:
 	/* rem: r6 = lock */
 	/* rem: r9 = new PCB */
@@ -366,8 +360,6 @@ ENTRY(cpu_switch)
 	mov	r1, #4
 	mov	lr, pc
 	ldr	pc, [r2, #CF_DCACHE_WB_RANGE]
-	mov	lr, pc
-	ldr	pc, [r2, #CF_L2CACHE_WB_RANGE]
 
 .Lcs_same_vector:
 #endif /* PMAP_INCLUDE_PTE_SYNC */
From raj at semihalf.com  Thu Oct 16 19:07:55 2008
From: raj at semihalf.com (Rafal Jaworowski)
Date: Thu Oct 16 19:08:07 2008
Subject: svn commit: r183866 - head/sys/dev/usb
In-Reply-To: <3bbf2fe10810141322o5ee27a2eka8a3a902ced6fc97@mail.gmail.com>
References: <200810140705.m9E75K3x098307@svn.freebsd.org>
	<3bbf2fe10810141322o5ee27a2eka8a3a902ced6fc97@mail.gmail.com>
Message-ID: <48F79107.1050301@semihalf.com>

Attilio Rao wrote:
[...]

>>
>>  Added: head/sys/dev/usb/ehci_mbus.c

[...]

> Why this includes lockmgr?
> I don't think it needs.

It seems required by ehci_softc: struct lock (sc_doorbell_lock) field.

Rafal
From phk at FreeBSD.org  Thu Oct 16 20:39:03 2008
From: phk at FreeBSD.org (Poul-Henning Kamp)
Date: Thu Oct 16 20:39:15 2008
Subject: svn commit: r183960 - head/usr.bin/ministat
Message-ID: <200810162039.m9GKd21b070051@svn.freebsd.org>

Author: phk
Date: Thu Oct 16 20:39:02 2008
New Revision: 183960
URL: http://svn.freebsd.org/changeset/base/183960

Log:
  Make ministat(1) vastly faster on huge datasets.

Modified:
  head/usr.bin/ministat/Makefile
  head/usr.bin/ministat/ministat.c

Modified: head/usr.bin/ministat/Makefile
==============================================================================
--- head/usr.bin/ministat/Makefile	Thu Oct 16 20:33:03 2008	(r183959)
+++ head/usr.bin/ministat/Makefile	Thu Oct 16 20:39:02 2008	(r183960)
@@ -8,7 +8,7 @@ LDADD=	-lm
 test:	${PROG}
 	./${PROG} < ${.CURDIR}/chameleon 
 	./${PROG} ${.CURDIR}/chameleon 
-	./${PROG} ${.CURDIR}/chameleon ${.CURDIR}/iguana
-	./${PROG} -c 80 ${.CURDIR}/chameleon ${.CURDIR}/iguana
+	./${PROG} ${.CURDIR}/iguana ${.CURDIR}/chameleon
+	./${PROG} -c 80 ${.CURDIR}/iguana ${.CURDIR}/chameleon
 	./${PROG} -s -c 80 ${.CURDIR}/chameleon ${.CURDIR}/iguana
 	./${PROG} -s -c 80 ${.CURDIR}/chameleon ${.CURDIR}/iguana ${.CURDIR}/iguana

Modified: head/usr.bin/ministat/ministat.c
==============================================================================
--- head/usr.bin/ministat/ministat.c	Thu Oct 16 20:33:03 2008	(r183959)
+++ head/usr.bin/ministat/ministat.c	Thu Oct 16 20:39:02 2008	(r183960)
@@ -131,11 +131,10 @@ double student [NSTUDENT + 1][NCONF] = {
 #define	MAX_DS	8
 static char symbol[MAX_DS] = { ' ', 'x', '+', '*', '%', '#', '@', 'O' };
 
-TAILQ_HEAD(pointlist, point);
-
 struct dataset {
 	char *name;
-	struct pointlist list;
+	double	*points;
+	unsigned lpoints;
 	double sy, syy;
 	int n;
 };
@@ -146,51 +145,39 @@ NewSet(void)
 	struct dataset *ds;
 
 	ds = calloc(1, sizeof *ds);
-	TAILQ_INIT(&ds->list);
+	ds->lpoints = 100000;
+	ds->points = calloc(sizeof *ds->points, ds->lpoints);
 	return(ds);
 }
 
-struct point {
-	TAILQ_ENTRY(point)	list;
-	double			val;
-};
-
 static void
 AddPoint(struct dataset *ds, double a)
 {
-	struct point *pp, *pp2;
+	double *dp;
 
-	pp = calloc(1, sizeof *pp);
-	pp->val = a;
-
-	ds->n++;
+	if (ds->n >= ds->lpoints) {
+		dp = ds->points;
+		ds->lpoints *= 4;
+		ds->points = calloc(sizeof *ds->points, ds->lpoints);
+		memcpy(ds->points, dp, sizeof *dp * ds->n);
+	}
+	ds->points[ds->n++] = a;
 	ds->sy += a;
 	ds->syy += a * a;
-	if (TAILQ_EMPTY(&ds->list)) {
-		TAILQ_INSERT_HEAD(&ds->list, pp, list);
-		return;
-	}
-	TAILQ_FOREACH(pp2, &ds->list, list) {
-		if (pp->val < pp2->val) {
-			TAILQ_INSERT_BEFORE(pp2, pp, list);
-			return;
-		}
-	}
-	TAILQ_INSERT_TAIL(&ds->list, pp, list);
 }
 
 static double
 Min(struct dataset *ds)
 {
 
-	return (TAILQ_FIRST(&ds->list)->val);
+	return (ds->points[0]);
 }
 
 static double
 Max(struct dataset *ds)
 {
 
-	return(TAILQ_LAST(&ds->list, pointlist)->val);
+	return (ds->points[ds->n -1]);
 }
 
 static double
@@ -206,23 +193,7 @@ Median(struct dataset *ds)
 	int even, i;
 	struct point *p1, *p2;
 
-	if ((ds->n % 2) == 1) {
-		i = (ds->n / 2) + 1;
-		even = 0;
-	} else {
-		i = ds->n / 2;
-		even = 1;
-	}
-	TAILQ_FOREACH(p1, &ds->list, list) {
-		--i;
-		if (i == 0)
-			break;
-	}
-	if (even) {
-		p2 = TAILQ_NEXT(p1, list);
-		return ((p2->val + p1->val) / 2);
-	}
-	return (p1->val);
+	return (ds->points[ds->n / 2]);
 }
 
 static double
@@ -346,7 +317,7 @@ PlotSet(struct dataset *ds, int val)
 {
 	struct plot *pl;
 	struct point *pp;
-	int i, j, m, x;
+	int i, j, m, x, n;
 	int bar;
 
 	pl = &plot;
@@ -370,8 +341,8 @@ PlotSet(struct dataset *ds, int val)
 	m = 1;
 	i = -1;
 	j = 0;
-	TAILQ_FOREACH(pp, &ds->list, list) {
-		x = (pp->val - pl->x0) / pl->dx;
+	for (n = 0; n < ds->n; n++) {
+		x = (ds->points[n] - pl->x0) / pl->dx;
 		if (x == i) {
 			j++;
 			if (j > m)
@@ -389,8 +360,8 @@ PlotSet(struct dataset *ds, int val)
 	}
 	pl->height = m;
 	i = -1;
-	TAILQ_FOREACH(pp, &ds->list, list) {
-		x = (pp->val - pl->x0) / pl->dx;
+	for (n = 0; n < ds->n; n++) {
+		x = (ds->points[n] - pl->x0) / pl->dx;
 		if (x == i) {
 			j++;
 		} else {
@@ -463,6 +434,19 @@ DumpPlot(void)
 	putchar('\n');
 }
 
+static int
+dbl_cmp(const void *a, const void *b)
+{
+	const double *aa = a;
+	const double *bb = b;
+
+	if (*aa < *bb)
+		return (-1);
+	else if (*aa > *bb)
+		return (1);
+	else
+		return (0);
+}
 
 static struct dataset *
 ReadSet(const char *n, int column, const char *delim)
@@ -515,6 +499,7 @@ ReadSet(const char *n, int column, const
 		    "Dataset %s must contain at least 3 data points\n", n);
 		exit (2);
 	}
+	qsort(s->points, s->n, sizeof *s->points, dbl_cmp);
 	return (s);
 }
 
From max at love2party.net  Thu Oct 16 20:50:04 2008
From: max at love2party.net (Max Laier)
Date: Thu Oct 16 20:50:16 2008
Subject: svn commit: r183960 - head/usr.bin/ministat
In-Reply-To: <200810162039.m9GKd21b070051@svn.freebsd.org>
References: <200810162039.m9GKd21b070051@svn.freebsd.org>
Message-ID: <200810162250.01303.max@love2party.net>

On Thursday 16 October 2008 22:39:02 Poul-Henning Kamp wrote:
> Author: phk
> Date: Thu Oct 16 20:39:02 2008
> New Revision: 183960
> URL: http://svn.freebsd.org/changeset/base/183960
>
> Log:
>   Make ministat(1) vastly faster on huge datasets.
>
> Modified:
>   head/usr.bin/ministat/Makefile
>   head/usr.bin/ministat/ministat.c
...
>  static void
>  AddPoint(struct dataset *ds, double a)
>  {
> -	struct point *pp, *pp2;
> +	double *dp;
>
> -	pp = calloc(1, sizeof *pp);
> -	pp->val = a;
> -
> -	ds->n++;
> +	if (ds->n >= ds->lpoints) {
> +		dp = ds->points;
> +		ds->lpoints *= 4;
> +		ds->points = calloc(sizeof *ds->points, ds->lpoints);
> +		memcpy(ds->points, dp, sizeof *dp * ds->n);

+ free(dp);

???

> +	}
> +	ds->points[ds->n++] = a;
>  	ds->sy += a;
>  	ds->syy += a * a;
> -	if (TAILQ_EMPTY(&ds->list)) {
> -		TAILQ_INSERT_HEAD(&ds->list, pp, list);
> -		return;
> -	}
> -	TAILQ_FOREACH(pp2, &ds->list, list) {
> -		if (pp->val < pp2->val) {
> -			TAILQ_INSERT_BEFORE(pp2, pp, list);
> -			return;
> -		}
> -	}
> -	TAILQ_INSERT_TAIL(&ds->list, pp, list);
>  }

-- 
/"\  Best regards,                      | mlaier@freebsd.org
\ /  Max Laier                          | ICQ #67774661
 X   http://pf4freebsd.love2party.net/  | mlaier@EFnet
/ \  ASCII Ribbon Campaign              | Against HTML Mail and News
From phk at FreeBSD.org  Thu Oct 16 20:56:11 2008
From: phk at FreeBSD.org (Poul-Henning Kamp)
Date: Thu Oct 16 20:56:17 2008
Subject: svn commit: r183961 - head/usr.bin/ministat
Message-ID: <200810162056.m9GKu91q070368@svn.freebsd.org>

Author: phk
Date: Thu Oct 16 20:56:09 2008
New Revision: 183961
URL: http://svn.freebsd.org/changeset/base/183961

Log:
  Free old arrays if we increase them.
  
  Pointed out by:	mlaier

Modified:
  head/usr.bin/ministat/ministat.c

Modified: head/usr.bin/ministat/ministat.c
==============================================================================
--- head/usr.bin/ministat/ministat.c	Thu Oct 16 20:39:02 2008	(r183960)
+++ head/usr.bin/ministat/ministat.c	Thu Oct 16 20:56:09 2008	(r183961)
@@ -160,6 +160,7 @@ AddPoint(struct dataset *ds, double a)
 		ds->lpoints *= 4;
 		ds->points = calloc(sizeof *ds->points, ds->lpoints);
 		memcpy(ds->points, dp, sizeof *dp * ds->n);
+		free(dp);
 	}
 	ds->points[ds->n++] = a;
 	ds->sy += a;
From imp at bsdimp.com  Thu Oct 16 21:10:25 2008
From: imp at bsdimp.com (M. Warner Losh)
Date: Thu Oct 16 21:10:39 2008
Subject: svn commit: r183896 - head/sys/dev/bge
In-Reply-To: <48F5053D.7070705@samsco.org>
References: <200810142028.m9EKShoL015514@svn.freebsd.org>
	<48F5053D.7070705@samsco.org>
Message-ID: <20081016.151012.1933498518.imp@bsdimp.com>

In message: <48F5053D.7070705@samsco.org>
            Scott Long  writes:
: Marius Strobl wrote:
: > Author: marius
: > Date: Tue Oct 14 20:28:42 2008
: > New Revision: 183896
: > URL: http://svn.freebsd.org/changeset/base/183896
: > 
: > Log:
: >   Use bus_{read,write}_4(9) instead of bus_space_{read,write}_4(9)
: >   in order to get rid of the bus space handle and tag in the softc.
: >   
: 
: Has anyone looked at the generated code from this interface switch and
: compared it what was getting generated previously?  Way back when,
: including  made bus_space_read|write_4() compile
: into a direct memory access on machines that supported it.  The dubious
: removal of bus_memio.h and bus_pio.h took away that benefit, and I'm
: afraid that it's only getting worse now.  Bus writes to card memory are
: still very important to high-performance devices and shouldn't be
: pessimized in the name of simpler-looking C code.

I've looked a little.  With changes similar to this change, the
generated code does look better because there's less stack traffic,
but it still isn't a direct write to memory without a function call...

Warner
From attilio at freebsd.org  Thu Oct 16 21:42:37 2008
From: attilio at freebsd.org (Attilio Rao)
Date: Thu Oct 16 21:42:43 2008
Subject: svn commit: r183866 - head/sys/dev/usb
In-Reply-To: <48F79107.1050301@semihalf.com>
References: <200810140705.m9E75K3x098307@svn.freebsd.org>
	<3bbf2fe10810141322o5ee27a2eka8a3a902ced6fc97@mail.gmail.com>
	<48F79107.1050301@semihalf.com>
Message-ID: <3bbf2fe10810161442h3be5dc5al1713aaa173636658@mail.gmail.com>

2008/10/16, Rafal Jaworowski :
> Attilio Rao wrote:
>  [...]
>
>
>  >>
>  >>  Added: head/sys/dev/usb/ehci_mbus.c
>
>
> [...]
>
>
>  > Why this includes lockmgr?
>  > I don't think it needs.
>
>
> It seems required by ehci_softc: struct lock (sc_doorbell_lock) field.

Ah gah.
IIRC, it was totally unuseful to use a lockmgr there.

I will wait for Hans' work to go in before to try to fix that issue.

Thanks,
Attilio


-- 
Peace can only be achieved by understanding - A. Einstein
From kmacy at FreeBSD.org  Fri Oct 17 01:25:45 2008
From: kmacy at FreeBSD.org (Kip Macy)
Date: Fri Oct 17 01:25:56 2008
Subject: svn commit: r183963 - head/sys/kern
Message-ID: <200810170125.m9H1PjE3074923@svn.freebsd.org>

Author: kmacy
Date: Fri Oct 17 01:25:45 2008
New Revision: 183963
URL: http://svn.freebsd.org/changeset/base/183963

Log:
  make sure that SO_NO_DDP and SO_NO_OFFLOAD get passed in correctly
  
  PR:		127360
  MFC after:	3 days

Modified:
  head/sys/kern/uipc_socket.c

Modified: head/sys/kern/uipc_socket.c
==============================================================================
--- head/sys/kern/uipc_socket.c	Thu Oct 16 22:45:07 2008	(r183962)
+++ head/sys/kern/uipc_socket.c	Fri Oct 17 01:25:45 2008	(r183963)
@@ -2194,6 +2194,8 @@ sosetopt(struct socket *so, struct socko
 		case SO_TIMESTAMP:
 		case SO_BINTIME:
 		case SO_NOSIGPIPE:
+		case SO_NO_DDP:
+		case SO_NO_OFFLOAD:
 			error = sooptcopyin(sopt, &optval, sizeof optval,
 					    sizeof optval);
 			if (error)
From yongari at FreeBSD.org  Fri Oct 17 05:26:52 2008
From: yongari at FreeBSD.org (Pyun YongHyeon)
Date: Fri Oct 17 05:27:03 2008
Subject: svn commit: r183966 - head/sys/dev/mii
Message-ID: <200810170526.m9H5QpbL079414@svn.freebsd.org>

Author: yongari
Date: Fri Oct 17 05:26:51 2008
New Revision: 183966
URL: http://svn.freebsd.org/changeset/base/183966

Log:
  Some 88E1149 PHY's page select is initialized to point to other
  bank instead of copper/fiber bank which in turn resulted in
  wrong registers were accessed during PHY operation. It is
  believed that page 0 should be used for copper PHY so reinitialize
  E1000_EADR to select default copper PHY.
  This fixes link establishment issue of nfe(4) on Sun Fire X4140.
  
  OpenBSD also has similimar patch but they just reset the E1000_EADR
  register to page 0. However some Marvell PHYs((88E3082, 88E1000)
  don't have the extended address register and the meaning of the
  register is quite different for each PHY model. So selecting copper
  PHY is limited to 88E1149 PHY which seems to be the only one that
  exhibits link establishment problem. If parent device know the type
  of PHY(either copper or fiber) that information should be notified
  to PHY driver but there is no good way to pass this information yet.
  
  Reported by:	thompsa
  Reviewed by:	thompsa

Modified:
  head/sys/dev/mii/e1000phy.c

Modified: head/sys/dev/mii/e1000phy.c
==============================================================================
--- head/sys/dev/mii/e1000phy.c	Fri Oct 17 03:59:25 2008	(r183965)
+++ head/sys/dev/mii/e1000phy.c	Fri Oct 17 05:26:51 2008	(r183966)
@@ -153,6 +153,20 @@ e1000phy_attach(device_t dev)
 		if (PHY_READ(sc, E1000_ESSR) & E1000_ESSR_FIBER_LINK)
 			sc->mii_flags |= MIIF_HAVEFIBER;
 		break;
+	case MII_MODEL_MARVELL_E1149:
+		/*
+		 * Some 88E1149 PHY's page select is initialized to
+		 * point to other bank instead of copper/fiber bank
+		 * which in turn resulted in wrong registers were
+		 * accessed during PHY operation. It is believed that
+		 * page 0 should be used for copper PHY so reinitialize
+		 * E1000_EADR to select default copper PHY. If parent
+		 * device know the type of PHY(either copper or fiber),
+		 * that information should be used to select default
+		 * type of PHY.
+		 */
+		PHY_WRITE(sc, E1000_EADR, 0);
+		break;
 	case MII_MODEL_MARVELL_E3082:
 		/* 88E3082 10/100 Fast Ethernet PHY. */
 		sc->mii_anegticks = MII_ANEGTICKS;
From kmacy at FreeBSD.org  Fri Oct 17 07:04:29 2008
From: kmacy at FreeBSD.org (Kip Macy)
Date: Fri Oct 17 07:04:41 2008
Subject: svn commit: r183967 - head/sys/dev/cxgb
Message-ID: <200810170704.m9H74TYZ081105@svn.freebsd.org>

Author: kmacy
Date: Fri Oct 17 07:04:29 2008
New Revision: 183967
URL: http://svn.freebsd.org/changeset/base/183967

Log:
  Track number of packets transmitted and number of packets received
  
  PR:	125806
  MFC after:	3 days

Modified:
  head/sys/dev/cxgb/cxgb_sge.c

Modified: head/sys/dev/cxgb/cxgb_sge.c
==============================================================================
--- head/sys/dev/cxgb/cxgb_sge.c	Fri Oct 17 05:26:51 2008	(r183966)
+++ head/sys/dev/cxgb/cxgb_sge.c	Fri Oct 17 07:04:29 2008	(r183967)
@@ -1887,7 +1887,11 @@ t3_free_tx_desc(struct sge_txq *q, int r
 			m_freem_iovec(&txsd->mi);	
 			buf_ring_scan(&q->txq_mr, txsd->mi.mi_base, __FILE__, __LINE__);
 			txsd->mi.mi_base = NULL;
-
+			/*
+			 * XXX check for cache hit rate here
+			 *
+			 */
+			q->port->ifp->if_opackets++;
 #if defined(DIAGNOSTIC) && 0
 			if (m_get_priority(txsd->m[0]) != cidx) 
 				printf("pri=%d cidx=%d\n",
@@ -2505,6 +2509,7 @@ t3_rx_eth(struct adapter *adap, struct s
 	
 	m->m_pkthdr.rcvif = ifp;
 	m->m_pkthdr.header = mtod(m, uint8_t *) + sizeof(*cpl) + ethpad;
+	ifp->if_ipackets++;
 #ifndef DISABLE_MBUF_IOVEC
 	m_explode(m);
 #endif	
From netchild at FreeBSD.org  Fri Oct 17 08:30:21 2008
From: netchild at FreeBSD.org (Alexander Leidinger)
Date: Fri Oct 17 08:30:42 2008
Subject: svn commit: r183969 - in head/lib/libc: . stdlib
Message-ID: <200810170830.m9H8UKtS082818@svn.freebsd.org>

Author: netchild
Date: Fri Oct 17 08:30:20 2008
New Revision: 183969
URL: http://svn.freebsd.org/changeset/base/183969

Log:
  MTC r183949:
   Allow to define MALLOC_PRODUCTION with a make variable instead of polluting
   the global CFLAGS.
  
  Reviewed by:	jasone

Modified:
  head/lib/libc/   (props changed)
  head/lib/libc/stdlib/Makefile.inc

Modified: head/lib/libc/stdlib/Makefile.inc
==============================================================================
--- head/lib/libc/stdlib/Makefile.inc	Fri Oct 17 07:39:27 2008	(r183968)
+++ head/lib/libc/stdlib/Makefile.inc	Fri Oct 17 08:30:20 2008	(r183969)
@@ -48,3 +48,8 @@ MLINKS+=strtoul.3 strtoull.3 strtoul.3 s
 MLINKS+=malloc.3 calloc.3 malloc.3 free.3 malloc.3 malloc.conf.5 \
 	malloc.3 realloc.3 malloc.3 reallocf.3 malloc.3 malloc_usable_size.3
 MLINKS+=tsearch.3 tdelete.3 tsearch.3 tfind.3 tsearch.3 twalk.3
+
+.if defined(MALLOC_PRODUCTION)
+CFLAGS+=	-DMALLOC_PRODUCTION
+.endif
+
From bzeeb-lists at lists.zabbadoz.net  Fri Oct 17 08:40:08 2008
From: bzeeb-lists at lists.zabbadoz.net (Bjoern A. Zeeb)
Date: Fri Oct 17 08:40:19 2008
Subject: svn commit: r183969 - in head/lib/libc: . stdlib
In-Reply-To: <200810170830.m9H8UKtS082818@svn.freebsd.org>
References: <200810170830.m9H8UKtS082818@svn.freebsd.org>
Message-ID: <20081017083900.I2978@maildrop.int.zabbadoz.net>

On Fri, 17 Oct 2008, Alexander Leidinger wrote:

> Author: netchild
> Date: Fri Oct 17 08:30:20 2008
> New Revision: 183969
> URL: http://svn.freebsd.org/changeset/base/183969
>
> Log:
>  MTC r183949:
>   Allow to define MALLOC_PRODUCTION with a make variable instead of polluting
>   the global CFLAGS.

I wonder if it would have been better to use the existing framework to
tunr on/off something that we use these days (src.conf)?


>  Reviewed by:	jasone
>
> Modified:
>  head/lib/libc/   (props changed)
>  head/lib/libc/stdlib/Makefile.inc
>
> Modified: head/lib/libc/stdlib/Makefile.inc
> ==============================================================================
> --- head/lib/libc/stdlib/Makefile.inc	Fri Oct 17 07:39:27 2008	(r183968)
> +++ head/lib/libc/stdlib/Makefile.inc	Fri Oct 17 08:30:20 2008	(r183969)
> @@ -48,3 +48,8 @@ MLINKS+=strtoul.3 strtoull.3 strtoul.3 s
> MLINKS+=malloc.3 calloc.3 malloc.3 free.3 malloc.3 malloc.conf.5 \
> 	malloc.3 realloc.3 malloc.3 reallocf.3 malloc.3 malloc_usable_size.3
> MLINKS+=tsearch.3 tdelete.3 tsearch.3 tfind.3 tsearch.3 twalk.3
> +
> +.if defined(MALLOC_PRODUCTION)
> +CFLAGS+=	-DMALLOC_PRODUCTION
> +.endif
> +
>

-- 
Bjoern A. Zeeb              Stop bit received. Insert coin for new game.
From bz at FreeBSD.org  Fri Oct 17 08:58:34 2008
From: bz at FreeBSD.org (Bjoern A. Zeeb)
Date: Fri Oct 17 08:58:46 2008
Subject: svn commit: r183970 - head/sys/security/mac_partition
Message-ID: <200810170858.m9H8wYCQ083301@svn.freebsd.org>

Author: bz
Date: Fri Oct 17 08:58:33 2008
New Revision: 183970
URL: http://svn.freebsd.org/changeset/base/183970

Log:
  Use the label from the socket credential rather than the
  solabel which was not set by the mac_partition policy.
  
  Spotted by:	rwatson
  Reviewed by:	rwatson
  MFC after:	3 days

Modified:
  head/sys/security/mac_partition/mac_partition.c

Modified: head/sys/security/mac_partition/mac_partition.c
==============================================================================
--- head/sys/security/mac_partition/mac_partition.c	Fri Oct 17 08:30:20 2008	(r183969)
+++ head/sys/security/mac_partition/mac_partition.c	Fri Oct 17 08:58:33 2008	(r183970)
@@ -51,6 +51,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -248,7 +249,7 @@ partition_socket_check_visible(struct uc
 {
 	int error;
 
-	error = label_on_label(cred->cr_label, solabel);
+	error = label_on_label(cred->cr_label, so->so_cred->cr_label);
 
 	return (error ? ENOENT : 0);
 }
From bz at FreeBSD.org  Fri Oct 17 12:54:29 2008
From: bz at FreeBSD.org (Bjoern A. Zeeb)
Date: Fri Oct 17 12:54:35 2008
Subject: svn commit: r183973 - head/sys/security/mac
Message-ID: <200810171254.m9HCsS4Q088609@svn.freebsd.org>

Author: bz
Date: Fri Oct 17 12:54:28 2008
New Revision: 183973
URL: http://svn.freebsd.org/changeset/base/183973

Log:
  Add mac_inpcb_check_visible MAC Framework entry point, which is similar
  to mac_socket_check_visible but operates on the inpcb.
  
  Reviewed by:	rwatson
  MFC after:	3 months (set timer, decide then)

Modified:
  head/sys/security/mac/mac_framework.h
  head/sys/security/mac/mac_inet.c
  head/sys/security/mac/mac_policy.h

Modified: head/sys/security/mac/mac_framework.h
==============================================================================
--- head/sys/security/mac/mac_framework.h	Fri Oct 17 12:04:59 2008	(r183972)
+++ head/sys/security/mac/mac_framework.h	Fri Oct 17 12:54:28 2008	(r183973)
@@ -131,6 +131,7 @@ int	mac_ifnet_ioctl_set(struct ucred *cr
 	    struct ifnet *ifp);
 
 int	mac_inpcb_check_deliver(struct inpcb *inp, struct mbuf *m);
+int	mac_inpcb_check_visible(struct ucred *cred, struct inpcb *inp);
 void	mac_inpcb_create(struct socket *so, struct inpcb *inp);
 void	mac_inpcb_create_mbuf(struct inpcb *inp, struct mbuf *m);
 void	mac_inpcb_destroy(struct inpcb *);

Modified: head/sys/security/mac/mac_inet.c
==============================================================================
--- head/sys/security/mac/mac_inet.c	Fri Oct 17 12:04:59 2008	(r183972)
+++ head/sys/security/mac/mac_inet.c	Fri Oct 17 12:54:28 2008	(r183973)
@@ -313,6 +313,18 @@ mac_inpcb_check_deliver(struct inpcb *in
 	return (error);
 }
 
+int
+mac_inpcb_check_visible(struct ucred *cred, struct inpcb *inp)
+{
+	int error;
+
+	INP_LOCK_ASSERT(inp);
+
+	MAC_CHECK(inpcb_check_visible, cred, inp, inp->inp_label);
+
+	return (error);
+}
+
 void
 mac_inpcb_sosetlabel(struct socket *so, struct inpcb *inp)
 {

Modified: head/sys/security/mac/mac_policy.h
==============================================================================
--- head/sys/security/mac/mac_policy.h	Fri Oct 17 12:04:59 2008	(r183972)
+++ head/sys/security/mac/mac_policy.h	Fri Oct 17 12:54:28 2008	(r183973)
@@ -187,6 +187,8 @@ typedef void	(*mpo_ifnet_relabel_t)(stru
 typedef int	(*mpo_inpcb_check_deliver_t)(struct inpcb *inp,
 		    struct label *inplabel, struct mbuf *m,
 		    struct label *mlabel);
+typedef int	(*mpo_inpcb_check_visible_t)(struct ucred *cred,
+		    struct inpcb *inp, struct label *inplabel);
 typedef void	(*mpo_inpcb_create_t)(struct socket *so,
 		    struct label *solabel, struct inpcb *inp,
 		    struct label *inplabel);
@@ -689,6 +691,7 @@ struct mac_policy_ops {
 	mpo_ifnet_relabel_t			mpo_ifnet_relabel;
 
 	mpo_inpcb_check_deliver_t		mpo_inpcb_check_deliver;
+	mpo_inpcb_check_visible_t		mpo_inpcb_check_visible;
 	mpo_inpcb_create_t			mpo_inpcb_create;
 	mpo_inpcb_create_mbuf_t			mpo_inpcb_create_mbuf;
 	mpo_inpcb_destroy_label_t		mpo_inpcb_destroy_label;
From brooks at FreeBSD.org  Fri Oct 17 13:28:54 2008
From: brooks at FreeBSD.org (Brooks Davis)
Date: Fri Oct 17 13:29:00 2008
Subject: svn commit: r183974 - head/sbin/dhclient
Message-ID: <200810171328.m9HDSrAo089234@svn.freebsd.org>

Author: brooks
Date: Fri Oct 17 13:28:53 2008
New Revision: 183974
URL: http://svn.freebsd.org/changeset/base/183974

Log:
  Support the remaining options listed in dhcp-options(5) and RFC 2132.
  
  PR:		bin/127076
  Submitted by:	jkim
  MFC after:	1 week

Modified:
  head/sbin/dhclient/dhclient.c
  head/sbin/dhclient/dhcp.h
  head/sbin/dhclient/tables.c

Modified: head/sbin/dhclient/dhclient.c
==============================================================================
--- head/sbin/dhclient/dhclient.c	Fri Oct 17 12:54:28 2008	(r183973)
+++ head/sbin/dhclient/dhclient.c	Fri Oct 17 13:28:53 2008	(r183974)
@@ -2317,12 +2317,16 @@ check_option(struct client_lease *l, int
 	case DHO_NETBIOS_DD_SERVER:
 	case DHO_FONT_SERVERS:
 	case DHO_DHCP_SERVER_IDENTIFIER:
+	case DHO_NISPLUS_SERVERS:
+	case DHO_MOBILE_IP_HOME_AGENT:
 	case DHO_SMTP_SERVER:
 	case DHO_POP_SERVER:
 	case DHO_NNTP_SERVER:
 	case DHO_WWW_SERVER:
 	case DHO_FINGER_SERVER:
 	case DHO_IRC_SERVER:
+	case DHO_STREETTALK_SERVER:
+	case DHO_STREETTALK_DA_SERVER:
 		if (!ipv4addrs(opbuf)) {
 			warning("Invalid IP address in option: %s", opbuf);
 			return (0);
@@ -2330,6 +2334,8 @@ check_option(struct client_lease *l, int
 		return (1)  ;
 	case DHO_HOST_NAME:
 	case DHO_NIS_DOMAIN:
+	case DHO_NISPLUS_DOMAIN:
+	case DHO_TFTP_SERVER_NAME:
 		if (!res_hnok(sbuf)) {
 			warning("Bogus Host Name option %d: %s (%s)", option,
 			    sbuf, opbuf);
@@ -2388,6 +2394,7 @@ check_option(struct client_lease *l, int
 	case DHO_DHCP_REBINDING_TIME:
 	case DHO_DHCP_CLASS_IDENTIFIER:
 	case DHO_DHCP_CLIENT_IDENTIFIER:
+	case DHO_BOOTFILE_NAME:
 	case DHO_DHCP_USER_CLASS_ID:
 	case DHO_END:
 		return (1);

Modified: head/sbin/dhclient/dhcp.h
==============================================================================
--- head/sbin/dhclient/dhcp.h	Fri Oct 17 12:54:28 2008	(r183973)
+++ head/sbin/dhclient/dhcp.h	Fri Oct 17 13:28:53 2008	(r183974)
@@ -155,12 +155,19 @@ struct dhcp_packet {
 #define DHO_DHCP_REBINDING_TIME		59
 #define DHO_DHCP_CLASS_IDENTIFIER	60
 #define DHO_DHCP_CLIENT_IDENTIFIER	61
+#define	DHO_NISPLUS_DOMAIN		64
+#define	DHO_NISPLUS_SERVERS		65
+#define	DHO_TFTP_SERVER_NAME		66
+#define	DHO_BOOTFILE_NAME		67
+#define	DHO_MOBILE_IP_HOME_AGENT	68
 #define DHO_SMTP_SERVER			69
 #define DHO_POP_SERVER			70
 #define DHO_NNTP_SERVER			71
 #define DHO_WWW_SERVER			72
 #define DHO_FINGER_SERVER		73
 #define DHO_IRC_SERVER			74
+#define	DHO_STREETTALK_SERVER		75
+#define	DHO_STREETTALK_DA_SERVER	76
 #define DHO_DHCP_USER_CLASS_ID		77
 #define DHO_CLASSLESS_ROUTES		121
 #define DHO_END				255

Modified: head/sbin/dhclient/tables.c
==============================================================================
--- head/sbin/dhclient/tables.c	Fri Oct 17 12:54:28 2008	(r183973)
+++ head/sbin/dhclient/tables.c	Fri Oct 17 13:28:53 2008	(r183974)
@@ -387,13 +387,25 @@ unsigned char dhcp_option_default_priori
 	DHO_FONT_SERVERS,
 	DHO_X_DISPLAY_MANAGER,
 	DHO_DHCP_PARAMETER_REQUEST_LIST,
+	DHO_NISPLUS_DOMAIN,
+	DHO_NISPLUS_SERVERS,
+	DHO_TFTP_SERVER_NAME,
+	DHO_BOOTFILE_NAME,
+	DHO_MOBILE_IP_HOME_AGENT,
+	DHO_SMTP_SERVER,
+	DHO_POP_SERVER,
+	DHO_NNTP_SERVER,
+	DHO_WWW_SERVER,
+	DHO_FINGER_SERVER,
+	DHO_IRC_SERVER,
+	DHO_STREETTALK_SERVER,
+	DHO_STREETTALK_DA_SERVER,
 
 	/* Presently-undefined options... */
-	62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
-	78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
-	93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
-	107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
-	119, 120, 122, 123, 124, 125, 126, 127, 128, 129, 130,
+	62, 63, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
+	92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
+	106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117,
+	118, 119, 120, 122, 123, 124, 125, 126, 127, 128, 129, 130,
 	131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142,
 	143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
 	155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166,
From philip at FreeBSD.org  Fri Oct 17 14:07:40 2008
From: philip at FreeBSD.org (Philip Paeps)
Date: Fri Oct 17 14:07:46 2008
Subject: svn commit: r183975 - head/share/syscons/keymaps
Message-ID: <200810171407.m9HE7dt9090040@svn.freebsd.org>

Author: philip
Date: Fri Oct 17 14:07:39 2008
New Revision: 183975
URL: http://svn.freebsd.org/changeset/base/183975

Log:
  Add the nordic keyboard layout for Asus eee devices.
  
  PR:		126841
  Submitted by:	Peter 
  MFC after:	3 days

Added:
  head/share/syscons/keymaps/eee_nordic.kbd   (contents, props changed)
Modified:
  head/share/syscons/keymaps/INDEX.keymaps

Modified: head/share/syscons/keymaps/INDEX.keymaps
==============================================================================
--- head/share/syscons/keymaps/INDEX.keymaps	Fri Oct 17 13:28:53 2008	(r183974)
+++ head/share/syscons/keymaps/INDEX.keymaps	Fri Oct 17 14:07:39 2008	(r183975)
@@ -99,6 +99,8 @@ danish.cp865.kbd:fr:Danois Code page 865
 danish.cp865.kbd:pt:Dinamarquês Codepage 865
 danish.cp865.kbd:es:Danés Codepage 865
 
+eee_nordic.kbd:en:Nordic layout on Asus eeePC
+
 el.iso07.kbd:en:Greek ISO-8859-7 (104 keys)
 el.iso07.kbd:el:Åëëçíéêü ISO-8859-7 (104 ðëÞêôñùí)
 

Added: head/share/syscons/keymaps/eee_nordic.kbd
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/share/syscons/keymaps/eee_nordic.kbd	Fri Oct 17 14:07:39 2008	(r183975)
@@ -0,0 +1,131 @@
+# $FreeBSD$
+#                                                         alt
+# scan                       cntrl          alt    alt   cntrl lock
+# code  base   shift  cntrl  shift  alt    shift  cntrl  shift state
+# ------------------------------------------------------------------
+  000   nop    nop    nop    nop    nop    nop    nop    nop     O
+  001   esc    esc    esc    esc    esc    esc    debug  esc     O
+  002   '1'    '!'    nop    nop    nop    nop    nop    nop     O
+  003   '2'    '"'    nul    nul    '@'    '@'    nul    nul     O
+  004   '3'    '#'    nop    nop    163    nop    nop    nop     O
+  005   '4'    164    nop    nop    '$'    nop    nop    nop     O
+  006   '5'    '%'    nop    nop    nop    nop    nop    nop     O
+  007   '6'    '&'    nop    nop    nop    nop    nop    nop     O
+# Alt + Shift + 7 = ÷
+  008   '7'    '/'    nop    nop    '{'    '÷'    nop    nop     O
+  009   '8'    '('    nop    nop    '['    nop    nop    nop     O
+  010   '9'    ')'    nop    nop    ']'    nop    gs     nop     O
+  011   '0'    '='    nop    nop    '}'    nop    nop    nop     O
+  012   '+'    '?'    nop    nop    '\'    nop    fs     nop     O
+# For left of backspace key, gives with Alt=' and Alt+Shift+Key=|
+  013   128    '`'    nop    nop    39     '|'    nop    nop     O
+  014   bs     bs     del    del    bs     bs     del    del     O
+  015   ht     btab   nop    nop    ht     btab   nop    nop     O
+  016   'q'    'Q'    dc1    dc1    'q'    'Q'    dc1    dc1     C
+  017   'w'    'W'    etb    etb    'w'    'W'    etb    etb     C
+# Alt + Ctrl + E = French e (as in café)
+  018   'e'    'E'    enq    enq    164    'E'    'é'    enq     C
+# Alt + R = Copyright sign
+  019   'r'    'R'    dc2    dc2    '®'    'R'    dc2    dc2     C
+  020   't'    'T'    dc4    dc4    't'    'T'    dc4    dc4     C
+  021   'y'    'Y'    em     em     'y'    'Y'    em     em      C
+# Alt + U = Mikro,  Alt + Shift + U = German u
+  022   'u'    'U'    nak    nak    'µ'    'U'    'ü'    'Ü'     C
+  023   'i'    'I'    ht     ht     'i'    'I'    ht     ht      C
+# Alt + O = Norwegian/Danish Ö
+  024   'o'    'O'    si     si     'ø'    'Ø'    si     si      C
+# Alt + P = Pi
+  025   'p'    'P'    dle    dle    '¶'    'P'    dle    dle     C
+  026   229    197    nop    nop    '}'    ']'    nop    nop     C
+  027   168    '^'    nop    nop    '~'    nop    nop    nop     O
+  028   cr     cr     nl     nl     cr     cr     nl     nl      O
+  029   lctrl  lctrl  lctrl  lctrl  lctrl  lctrl  lctrl  lctrl   O
+# Alt + A = At sign,  Ctrl+Alt = ae,  Ctrl+Alt+Shift = AE
+  030   'a'    'A'    soh    soh    '@'    'A'    'æ'    'Æ'     C
+  031   's'    'S'    dc3    dc3    's'    'S'    dc3    dc3     C
+  032   'd'    'D'    eot    eot    'd'    'D'    eot    eot     C
+  033   'f'    'F'    ack    ack    'f'    'F'    ack    ack     C
+  034   'g'    'G'    bel    bel    'g'    'G'    bel    bel     C
+  035   'h'    'H'    bs     bs     'h'    'H'    bs     bs      C
+  036   'j'    'J'    nl     nl     'j'    'J'    nl     nl      C
+  037   'k'    'K'    vt     vt     'k'    'K'    vt     vt      C
+  038   'l'    'L'    ff     ff     'l'    'L'    ff     ff      C
+  039   246    214    nop    nop    '|'    '\'    nop    nop     C
+  040   228    196    nop    nop    '{'    '['    nop    nop     C
+  041   167    189    nop    nop    '\'    '|'    nop    nop     O
+  042   lshift lshift lshift lshift lshift lshift lshift lshift  O
+  043   '''    '*'    nop    nop    nop    nop    nop    nop     O
+# Alt + Z = Pipe
+  044   'z'    'Z'    sub    sub    '|'    'Z'    sub    sub     C
+  045   'x'    'X'    can    can    'x'    'X'    can    can     C
+  046   'c'    'C'    etx    etx    'c'    'C'    etx    etx     C
+  047   'v'    'V'    syn    syn    'v'    'V'    syn    syn     C
+# Ctrl + Shift + B = German B
+  048   'b'    'B'    stx    'ß'    'b'    'B'    stx    stx     C
+  049   'n'    'N'    so     so     'n'    'N'    so     so      C
+# Alt + M = Mikro
+  050   'm'    'M'    cr     cr     181    'M'    cr     cr      C
+# Alt + [,/;] = <
+  051   ','    ';'    nop    nop    '<'    '<'    nop    nop     O
+# Alt + [./:] = >
+  052   '.'    ':'    nop    nop    '>'    '>'    nop    nop     O
+  053   '-'    '_'    us     nop    '/'    '?'    nop    nop     O
+  054   rshift rshift rshift rshift rshift rshift rshift rshift  O
+  055   '*'    '*'    '*'    '*'    '*'    '*'    '*'    '*'     O
+  056   lalt   lalt   lalt   lalt   lalt   lalt   lalt   lalt    O
+  057   ' '    ' '    nul    ' '    ' '    ' '    susp   ' '     O
+  058   clock  clock  clock  clock  clock  clock  clock  clock   O
+  059   fkey01 fkey13 fkey25 fkey37 scr01  scr11  scr01  scr11   O
+  060   fkey02 fkey14 fkey26 fkey38 scr02  scr12  scr02  scr12   O
+  061   fkey03 fkey15 fkey27 fkey39 scr03  scr13  scr03  scr13   O
+  062   fkey04 fkey16 fkey28 fkey40 scr04  scr14  scr04  scr14   O
+  063   fkey05 fkey17 fkey29 fkey41 scr05  scr15  scr05  scr15   O
+  064   fkey06 fkey18 fkey30 fkey42 scr06  scr16  scr06  scr16   O
+  065   fkey07 fkey19 fkey31 fkey43 scr07  scr07  scr07  scr07   O
+  066   fkey08 fkey20 fkey32 fkey44 scr08  scr08  scr08  scr08   O
+  067   fkey09 fkey21 fkey33 fkey45 scr09  scr09  scr09  scr09   O
+  068   fkey10 fkey22 fkey34 fkey46 scr10  scr10  scr10  scr10   O
+  069   nlock  nlock  nlock  nlock  nlock  nlock  nlock  nlock   O
+  070   slock  slock  slock  slock  slock  slock  slock  slock   O
+  071   fkey49 '7'    '7'    '7'    '7'    '7'    '7'    '7'     N
+  072   fkey50 '8'    '8'    '8'    '8'    '8'    '8'    '8'     N
+  073   fkey51 '9'    '9'    '9'    '9'    '9'    '9'    '9'     N
+  074   fkey52 '-'    '-'    '-'    '-'    '-'    '-'    '-'     N
+  075   fkey53 '4'    '4'    '4'    '4'    '4'    '4'    '4'     N
+  076   fkey54 '5'    '5'    '5'    '5'    '5'    '5'    '5'     N
+  077   fkey55 '6'    '6'    '6'    '6'    '6'    '6'    '6'     N
+  078   fkey56 '+'    '+'    '+'    '+'    '+'    '+'    '+'     N
+  079   fkey57 '1'    '1'    '1'    '1'    '1'    '1'    '1'     N
+  080   fkey58 '2'    '2'    '2'    '2'    '2'    '2'    '2'     N
+  081   fkey59 '3'    '3'    '3'    '3'    '3'    '3'    '3'     N
+  082   fkey60 '0'    '0'    '0'    '0'    '0'    '0'    '0'     N
+  083   del    '.'    '.'    '.'    '.'    '.'    boot   boot    N
+  084   nop    nop    nop    nop    nop    nop    nop    nop     O
+  085   nop    nop    nop    nop    nop    nop    nop    nop     O
+  086   '<'    '>'    nop    nop    '|'    nop    nop    nop     O
+  087   fkey11 fkey23 fkey35 fkey47 scr11  scr11  scr11  scr11   O
+  088   fkey12 fkey24 fkey36 fkey48 scr12  scr12  scr12  scr12   O
+  089   cr     cr     nl     nl     cr     cr     nl     nl      O
+  090   rctrl  rctrl  rctrl  rctrl  rctrl  rctrl  rctrl  rctrl   O
+  091   '/'    '/'    '/'    '/'    '/'    '/'    '/'    '/'     N
+  092   nscr   pscr   debug  debug  nop    nop    nop    nop     O
+  093   ralt   ralt   ralt   ralt   ralt   ralt   ralt   ralt    O
+  094   fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49  O
+# Alt+Arrow up = Page up
+  095   fkey50 fkey50 fkey50 fkey50 fkey51 fkey50 fkey50 fkey50  O
+  096   fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51  O
+# Alt+Arrow left = Home
+  097   fkey53 fkey53 fkey53 fkey53 fkey49 fkey53 fkey53 fkey53  O
+# Alt+Arrow right = End
+  098   fkey55 fkey55 fkey55 fkey55 fkey57 fkey55 fkey55 fkey55  O
+  099   fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57  O
+# Alt+Arrow down = Page down
+  100   fkey58 fkey58 fkey58 fkey58 fkey59 fkey58 fkey58 fkey58  O
+  101   fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59  O
+  102   fkey60 paste  fkey60 fkey60 fkey60 fkey60 fkey60 fkey60  O
+  103	fkey61 fkey61 fkey61 fkey61 fkey61 fkey61 boot   fkey61  O
+  104   slock  saver  slock  saver  susp   nop    susp   nop     O
+  105   fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62  O
+  106   fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63  O
+  107   fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64  O
+  108   nop    nop    nop    nop    nop    nop    nop    nop     O
From brooks at FreeBSD.org  Fri Oct 17 14:37:58 2008
From: brooks at FreeBSD.org (Brooks Davis)
Date: Fri Oct 17 14:38:10 2008
Subject: svn commit: r183976 - head/sys/dev/usb
Message-ID: <200810171437.m9HEbwTP090639@svn.freebsd.org>

Author: brooks
Date: Fri Oct 17 14:37:58 2008
New Revision: 183976
URL: http://svn.freebsd.org/changeset/base/183976

Log:
  Wireless Mouse device of Sony VGP-WRC1 mouse/keyboard receiver has the
  same program interface as Microsoft Wireless Notebook Optical Mouse and
  needs a quirk.
  
  PR:		usb/122712
  MFC after:	3 days

Modified:
  head/sys/dev/usb/usb_quirks.c
  head/sys/dev/usb/usbdevs

Modified: head/sys/dev/usb/usb_quirks.c
==============================================================================
--- head/sys/dev/usb/usb_quirks.c	Fri Oct 17 14:07:39 2008	(r183975)
+++ head/sys/dev/usb/usb_quirks.c	Fri Oct 17 14:37:58 2008	(r183976)
@@ -90,6 +90,8 @@ static const struct usbd_quirk_entry {
    ANY, { UQ_MS_BAD_CLASS | UQ_MS_LEADING_BYTE }},
  { USB_VENDOR_MICROSOFT, USB_PRODUCT_MICROSOFT_WLINTELLIMOUSE,
    ANY, { UQ_MS_LEADING_BYTE }},
+ { USB_VENDOR_SONY, USB_PRODUCT_SONY_RF_RECEIVER,
+   ANY,{ UQ_MS_BAD_CLASS }},
 
  /* Devices which should be ignored by uhid */
  { USB_VENDOR_APC, USB_PRODUCT_APC_UPS,

Modified: head/sys/dev/usb/usbdevs
==============================================================================
--- head/sys/dev/usb/usbdevs	Fri Oct 17 14:07:39 2008	(r183975)
+++ head/sys/dev/usb/usbdevs	Fri Oct 17 14:37:58 2008	(r183976)
@@ -2232,6 +2232,7 @@ product SONY CLIE_41		0x009a	Sony Clie v
 product SONY CLIE_NX60		0x00da	Sony Clie nx60
 product SONY CLIE_TH55		0x0144	Sony Clie th55
 product SONY CLIE_TJ37		0x0169	Sony Clie tj37
+product SONY RF_RECEIVER	0x01db	Sony RF mouse/kbd Receiver VGP-WRC1
 
 /* Sony Ericsson products */
 product SONYERICSSON DCU10	0x0528	USB Cable
From philip at FreeBSD.org  Fri Oct 17 14:40:04 2008
From: philip at FreeBSD.org (Philip Paeps)
Date: Fri Oct 17 14:40:15 2008
Subject: svn commit: r183977 - head/usr.sbin/sysinstall
Message-ID: <200810171440.m9HEe4NB090723@svn.freebsd.org>

Author: philip
Date: Fri Oct 17 14:40:03 2008
New Revision: 183977
URL: http://svn.freebsd.org/changeset/base/183977

Log:
  Adjust default keymaps for Ireland and Channel Islands.  They use the UK
  keymap.  You can learn some interesting things in the PR database!
  
  PR:		conf/124411
  Submitted by:	Doctor Modiford 
  MFC after:	3 days

Modified:
  head/usr.sbin/sysinstall/keymap.c

Modified: head/usr.sbin/sysinstall/keymap.c
==============================================================================
--- head/usr.sbin/sysinstall/keymap.c	Fri Oct 17 14:37:58 2008	(r183976)
+++ head/usr.sbin/sysinstall/keymap.c	Fri Oct 17 14:40:03 2008	(r183977)
@@ -82,6 +82,10 @@ keymapMenuSelect(dialogMenuItem *self)
 	{"se", "swedish"},
 	{"ch", "swiss"},
 	{"gb", "uk"},
+	{"gg", "uk"},
+	{"ie", "uk"},
+	{"im", "uk"},
+	{"je", "uk"},
 	{NULL, NULL}
     };
     const char *country, *lang;
From brooks at FreeBSD.org  Fri Oct 17 15:10:45 2008
From: brooks at FreeBSD.org (Brooks Davis)
Date: Fri Oct 17 15:11:04 2008
Subject: svn commit: r183979 - head/usr.sbin/pkg_install/add
Message-ID: <200810171510.m9HFAjWf091325@svn.freebsd.org>

Author: brooks
Date: Fri Oct 17 15:10:45 2008
New Revision: 183979
URL: http://svn.freebsd.org/changeset/base/183979

Log:
  Display usage when pkg_add is called with no arguments.
  
  PR:		bin/121093
  Submitted by:	volker
  Approved by:	portmgr (linimon)
  MFC after:	3 days

Modified:
  head/usr.sbin/pkg_install/add/main.c

Modified: head/usr.sbin/pkg_install/add/main.c
==============================================================================
--- head/usr.sbin/pkg_install/add/main.c	Fri Oct 17 15:06:34 2008	(r183978)
+++ head/usr.sbin/pkg_install/add/main.c	Fri Oct 17 15:10:45 2008	(r183979)
@@ -259,7 +259,7 @@ main(int argc, char **argv)
 	}
     }
     /* If no packages, yelp */
-    else if (!ch) {
+    if (!ch) {
 	warnx("missing package name(s)");
 	usage();
     }
From bz at FreeBSD.org  Fri Oct 17 15:11:12 2008
From: bz at FreeBSD.org (Bjoern A. Zeeb)
Date: Fri Oct 17 15:11:37 2008
Subject: svn commit: r183980 - in head/sys/security: mac_biba mac_lomac
	mac_mls mac_partition mac_seeotheruids mac_stub mac_test
Message-ID: <200810171511.m9HFBC6c091384@svn.freebsd.org>

Author: bz
Date: Fri Oct 17 15:11:12 2008
New Revision: 183980
URL: http://svn.freebsd.org/changeset/base/183980

Log:
  Add a mac_inpcb_check_visible implementation to all MAC policies
  that handle mac_socket_check_visible.
  
  Reviewed by:	rwatson
  MFC after:	3 months (set timer; decide then)

Modified:
  head/sys/security/mac_biba/mac_biba.c
  head/sys/security/mac_lomac/mac_lomac.c
  head/sys/security/mac_mls/mac_mls.c
  head/sys/security/mac_partition/mac_partition.c
  head/sys/security/mac_seeotheruids/mac_seeotheruids.c
  head/sys/security/mac_stub/mac_stub.c
  head/sys/security/mac_test/mac_test.c

Modified: head/sys/security/mac_biba/mac_biba.c
==============================================================================
--- head/sys/security/mac_biba/mac_biba.c	Fri Oct 17 15:10:45 2008	(r183979)
+++ head/sys/security/mac_biba/mac_biba.c	Fri Oct 17 15:11:12 2008	(r183980)
@@ -1115,6 +1115,24 @@ biba_inpcb_check_deliver(struct inpcb *i
 	return (biba_equal_effective(p, i) ? 0 : EACCES);
 }
 
+static int
+biba_inpcb_check_visible(struct ucred *cred, struct inpcb *inp,
+    struct label *inplabel)
+{
+	struct mac_biba *subj, *obj;
+
+	if (!biba_enabled)
+		return (0);
+
+	subj = SLOT(cred->cr_label);
+	obj = SLOT(inplabel);
+
+	if (!biba_dominate_effective(obj, subj))
+		return (ENOENT);
+
+	return (0);
+}
+
 static void
 biba_inpcb_create(struct socket *so, struct label *solabel,
     struct inpcb *inp, struct label *inplabel)
@@ -3300,6 +3318,7 @@ static struct mac_policy_ops mac_biba_op
 	.mpo_ifnet_relabel = biba_ifnet_relabel,
 
 	.mpo_inpcb_check_deliver = biba_inpcb_check_deliver,
+	.mpo_inpcb_check_visible = biba_inpcb_check_visible,
 	.mpo_inpcb_create = biba_inpcb_create,
 	.mpo_inpcb_create_mbuf = biba_inpcb_create_mbuf,
 	.mpo_inpcb_destroy_label = biba_destroy_label,

Modified: head/sys/security/mac_lomac/mac_lomac.c
==============================================================================
--- head/sys/security/mac_lomac/mac_lomac.c	Fri Oct 17 15:10:45 2008	(r183979)
+++ head/sys/security/mac_lomac/mac_lomac.c	Fri Oct 17 15:11:12 2008	(r183980)
@@ -1244,6 +1244,24 @@ lomac_inpcb_check_deliver(struct inpcb *
 	return (lomac_equal_single(p, i) ? 0 : EACCES);
 }
 
+static int
+lomac_inpcb_check_visible(struct ucred *cred, struct inpcb *inp,
+    struct label *inplabel)
+{
+	struct mac_lomac *subj, *obj;
+
+	if (!lomac_enabled)
+		return (0);
+
+	subj = SLOT(cred->cr_label);
+	obj = SLOT(inplabel);
+
+	if (!lomac_dominate_single(obj, subj))
+		return (ENOENT);
+
+	return (0);
+}
+
 static void
 lomac_inpcb_create(struct socket *so, struct label *solabel,
     struct inpcb *inp, struct label *inplabel)
@@ -2861,6 +2879,7 @@ static struct mac_policy_ops lomac_ops =
 	.mpo_syncache_init_label = lomac_init_label_waitcheck,
 
 	.mpo_inpcb_check_deliver = lomac_inpcb_check_deliver,
+	.mpo_inpcb_check_visible = lomac_inpcb_check_visible,
 	.mpo_inpcb_create = lomac_inpcb_create,
 	.mpo_inpcb_create_mbuf = lomac_inpcb_create_mbuf,
 	.mpo_inpcb_destroy_label = lomac_destroy_label,

Modified: head/sys/security/mac_mls/mac_mls.c
==============================================================================
--- head/sys/security/mac_mls/mac_mls.c	Fri Oct 17 15:10:45 2008	(r183979)
+++ head/sys/security/mac_mls/mac_mls.c	Fri Oct 17 15:11:12 2008	(r183980)
@@ -1033,6 +1033,24 @@ mls_inpcb_check_deliver(struct inpcb *in
 	return (mls_equal_effective(p, i) ? 0 : EACCES);
 }
 
+static int
+mls_inpcb_check_visible(struct ucred *cred, struct inpcb *inp,
+    struct label *inplabel)
+{
+	struct mac_mls *subj, *obj;
+
+	if (!mls_enabled)
+		return (0);
+
+	subj = SLOT(cred->cr_label);
+	obj = SLOT(inplabel);
+
+	if (!mls_dominate_effective(subj, obj))
+		return (ENOENT);
+
+	return (0);
+}
+
 static void
 mls_inpcb_create(struct socket *so, struct label *solabel, struct inpcb *inp,
     struct label *inplabel)
@@ -2923,6 +2941,7 @@ static struct mac_policy_ops mls_ops =
 	.mpo_ifnet_relabel = mls_ifnet_relabel,
 
 	.mpo_inpcb_check_deliver = mls_inpcb_check_deliver,
+	.mpo_inpcb_check_visible = mls_inpcb_check_visible,
 	.mpo_inpcb_create = mls_inpcb_create,
 	.mpo_inpcb_create_mbuf = mls_inpcb_create_mbuf,
 	.mpo_inpcb_destroy_label = mls_destroy_label,

Modified: head/sys/security/mac_partition/mac_partition.c
==============================================================================
--- head/sys/security/mac_partition/mac_partition.c	Fri Oct 17 15:10:45 2008	(r183979)
+++ head/sys/security/mac_partition/mac_partition.c	Fri Oct 17 15:11:12 2008	(r183980)
@@ -51,10 +51,15 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 
+#include 
+#include 
+#include 
+
 #include 
 #include 
 
@@ -199,6 +204,17 @@ partition_cred_relabel(struct ucred *cre
 }
 
 static int
+partition_inpcb_check_visible(struct ucred *cred, struct inpcb *inp,
+    struct label *inplabel)
+{
+	int error;
+
+	error = label_on_label(cred->cr_label, inp->inp_cred->cr_label);
+
+	return (error ? ENOENT : 0);
+}
+
+static int
 partition_proc_check_debug(struct ucred *cred, struct proc *p)
 {
 	int error;
@@ -283,6 +299,7 @@ static struct mac_policy_ops partition_o
 	.mpo_cred_init_label = partition_cred_init_label,
 	.mpo_cred_internalize_label = partition_cred_internalize_label,
 	.mpo_cred_relabel = partition_cred_relabel,
+	.mpo_inpcb_check_visible = partition_inpcb_check_visible,
 	.mpo_proc_check_debug = partition_proc_check_debug,
 	.mpo_proc_check_sched = partition_proc_check_sched,
 	.mpo_proc_check_signal = partition_proc_check_signal,

Modified: head/sys/security/mac_seeotheruids/mac_seeotheruids.c
==============================================================================
--- head/sys/security/mac_seeotheruids/mac_seeotheruids.c	Fri Oct 17 15:10:45 2008	(r183979)
+++ head/sys/security/mac_seeotheruids/mac_seeotheruids.c	Fri Oct 17 15:11:12 2008	(r183980)
@@ -51,9 +51,14 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
+#include 
+#include 
+#include 
+
 #include 
 
 SYSCTL_DECL(_security_mac);
@@ -155,6 +160,14 @@ seeotheruids_cred_check_visible(struct u
 }
 
 static int
+seeotheruids_inpcb_check_visible(struct ucred *cred, struct inpcb *inp,
+    struct label *inplabel)
+{
+
+	return (seeotheruids_check(cred, inp->inp_cred));
+}
+
+static int
 seeotheruids_socket_check_visible(struct ucred *cred, struct socket *so,
     struct label *solabel)
 {
@@ -168,6 +181,7 @@ static struct mac_policy_ops seeotheruid
 	.mpo_proc_check_sched = seeotheruids_proc_check_sched,
 	.mpo_proc_check_signal = seeotheruids_proc_check_signal,
 	.mpo_cred_check_visible = seeotheruids_cred_check_visible,
+	.mpo_inpcb_check_visible = seeotheruids_inpcb_check_visible,
 	.mpo_socket_check_visible = seeotheruids_socket_check_visible,
 };
 

Modified: head/sys/security/mac_stub/mac_stub.c
==============================================================================
--- head/sys/security/mac_stub/mac_stub.c	Fri Oct 17 15:10:45 2008	(r183979)
+++ head/sys/security/mac_stub/mac_stub.c	Fri Oct 17 15:11:12 2008	(r183980)
@@ -859,6 +859,14 @@ stub_socket_check_stat(struct ucred *cre
 }
 
 static int
+stub_inpcb_check_visible(struct ucred *cred, struct inpcb *inp,
+   struct label *inplabel)
+{
+
+	return (0);
+}
+
+static int
 stub_socket_check_visible(struct ucred *cred, struct socket *so,
    struct label *solabel)
 {
@@ -1531,6 +1539,7 @@ static struct mac_policy_ops stub_ops =
 	.mpo_ifnet_relabel = stub_ifnet_relabel,
 
 	.mpo_inpcb_check_deliver = stub_inpcb_check_deliver,
+	.mpo_inpcb_check_visible = stub_inpcb_check_visible,
 	.mpo_inpcb_create = stub_inpcb_create,
 	.mpo_inpcb_create_mbuf = stub_inpcb_create_mbuf,
 	.mpo_inpcb_destroy_label = stub_destroy_label,

Modified: head/sys/security/mac_test/mac_test.c
==============================================================================
--- head/sys/security/mac_test/mac_test.c	Fri Oct 17 15:10:45 2008	(r183979)
+++ head/sys/security/mac_test/mac_test.c	Fri Oct 17 15:11:12 2008	(r183980)
@@ -494,6 +494,19 @@ test_inpcb_check_deliver(struct inpcb *i
 	return (0);
 }
 
+COUNTER_DECL(inpcb_check_visible);
+static int
+test_inpcb_check_visible(struct ucred *cred, struct inpcb *inp,
+    struct label *inplabel)
+{
+
+	LABEL_CHECK(cred->cr_label, MAGIC_CRED);
+	LABEL_CHECK(inplabel, MAGIC_INPCB);
+	COUNTER_INC(inpcb_check_visible);
+
+	return (0);
+}
+
 COUNTER_DECL(inpcb_create);
 static void
 test_inpcb_create(struct socket *so, struct label *solabel,
@@ -2840,6 +2853,7 @@ static struct mac_policy_ops test_ops =
 	.mpo_sysvshm_init_label = test_sysvshm_init_label,
 
 	.mpo_inpcb_check_deliver = test_inpcb_check_deliver,
+	.mpo_inpcb_check_visible = test_inpcb_check_visible,
 	.mpo_inpcb_create = test_inpcb_create,
 	.mpo_inpcb_create_mbuf = test_inpcb_create_mbuf,
 	.mpo_inpcb_destroy_label = test_inpcb_destroy_label,
From jhb at FreeBSD.org  Fri Oct 17 16:03:38 2008
From: jhb at FreeBSD.org (John Baldwin)
Date: Fri Oct 17 16:03:50 2008
Subject: svn commit: r183981 - head/sys/dev/ata/chipsets
Message-ID: <200810171603.m9HG3buK092293@svn.freebsd.org>

Author: jhb
Date: Fri Oct 17 16:03:37 2008
New Revision: 183981
URL: http://svn.freebsd.org/changeset/base/183981

Log:
  - For chipsets that can't do 64k transfers, fall back to 32k transfers
    (still a power of 2) rather than 63k transfers.  Even with 63k transfers
    some machines (such as Dell SC1435's) were experiencing chronic data
    corruption.
  - Use the MIO method to talk to the Serverworks HT1000_S1 SATA controller
    like all the other SATA controllers rather than the compat PATA
    method.  This lets the controller see all 4 SATA ports and also
    matches the behavior of the Linux driver.
  
  Silence from:	sos
  MFC after:	3 days

Modified:
  head/sys/dev/ata/chipsets/ata-cyrix.c
  head/sys/dev/ata/chipsets/ata-marvell.c
  head/sys/dev/ata/chipsets/ata-national.c
  head/sys/dev/ata/chipsets/ata-serverworks.c

Modified: head/sys/dev/ata/chipsets/ata-cyrix.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-cyrix.c	Fri Oct 17 15:11:12 2008	(r183980)
+++ head/sys/dev/ata/chipsets/ata-cyrix.c	Fri Oct 17 16:03:37 2008	(r183981)
@@ -109,7 +109,7 @@ ata_cyrix_setmode(device_t dev, int mode
 	/* dont try to set the mode if we dont have the resource */
 	if (ctlr->r_res1) {
 	    ch->dma.alignment = 16;
-	    ch->dma.max_iosize = 126 * DEV_BSIZE;
+	    ch->dma.max_iosize = 64 * DEV_BSIZE;
 
 	    if (mode >= ATA_UDMA0) {
 		ATA_OUTL(ch->r_io[ATA_BMCMD_PORT].res,

Modified: head/sys/dev/ata/chipsets/ata-marvell.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-marvell.c	Fri Oct 17 15:11:12 2008	(r183980)
+++ head/sys/dev/ata/chipsets/ata-marvell.c	Fri Oct 17 16:03:37 2008	(r183981)
@@ -536,7 +536,7 @@ ata_marvell_edma_dmainit(device_t dev)
 	ch->dma.max_address = BUS_SPACE_MAXADDR;
 
     /* chip does not reliably do 64K DMA transfers */
-    ch->dma.max_iosize = 126 * DEV_BSIZE; 
+    ch->dma.max_iosize = 64 * DEV_BSIZE; 
 }
 
 ATA_DECLARE_DRIVER(ata_marvell);

Modified: head/sys/dev/ata/chipsets/ata-national.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-national.c	Fri Oct 17 15:11:12 2008	(r183980)
+++ head/sys/dev/ata/chipsets/ata-national.c	Fri Oct 17 16:03:37 2008	(r183981)
@@ -101,7 +101,7 @@ ata_national_setmode(device_t dev, int m
     int error;
 
     ch->dma.alignment = 16;
-    ch->dma.max_iosize = 126 * DEV_BSIZE;
+    ch->dma.max_iosize = 64 * DEV_BSIZE;
 
     mode = ata_limit_mode(dev, mode, ATA_UDMA2);
 

Modified: head/sys/dev/ata/chipsets/ata-serverworks.c
==============================================================================
--- head/sys/dev/ata/chipsets/ata-serverworks.c	Fri Oct 17 15:11:12 2008	(r183980)
+++ head/sys/dev/ata/chipsets/ata-serverworks.c	Fri Oct 17 16:03:37 2008	(r183981)
@@ -79,7 +79,7 @@ ata_serverworks_probe(device_t dev)
      { ATA_CSB6,      0x00, SWKS_100, 0, ATA_UDMA5, "CSB6" },
      { ATA_CSB6_1,    0x00, SWKS_66,  0, ATA_UDMA4, "CSB6" },
      { ATA_HT1000,    0x00, SWKS_100, 0, ATA_UDMA5, "HT1000" },
-     { ATA_HT1000_S1, 0x00, SWKS_100, 4, ATA_SA150, "HT1000" },
+     { ATA_HT1000_S1, 0x00, SWKS_MIO, 4, ATA_SA150, "HT1000" },
      { ATA_HT1000_S2, 0x00, SWKS_MIO, 4, ATA_SA150, "HT1000" },
      { ATA_K2,        0x00, SWKS_MIO, 4, ATA_SA150, "K2" },
      { ATA_FRODO4,    0x00, SWKS_MIO, 4, ATA_SA150, "Frodo4" },
@@ -184,7 +184,7 @@ ata_serverworks_allocate(device_t dev)
     ch->hw.tf_write = ata_serverworks_tf_write;
 
     /* chip does not reliably do 64K DMA transfers */
-    ch->dma.max_iosize = 126 * DEV_BSIZE;
+    ch->dma.max_iosize = 64 * DEV_BSIZE;
 
     return 0;
 }
From bz at FreeBSD.org  Fri Oct 17 16:26:17 2008
From: bz at FreeBSD.org (Bjoern A. Zeeb)
Date: Fri Oct 17 16:26:29 2008
Subject: svn commit: r183982 - in head/sys: kern netinet sys
Message-ID: <200810171626.m9HGQG6v092747@svn.freebsd.org>

Author: bz
Date: Fri Oct 17 16:26:16 2008
New Revision: 183982
URL: http://svn.freebsd.org/changeset/base/183982

Log:
  Add cr_canseeinpcb() doing checks using the cached socket
  credentials from inp_cred which is also available after the
  socket is gone.
  Switch cr_canseesocket consumers to cr_canseeinpcb.
  This removes an extra acquisition of the socket lock.
  
  Reviewed by:	rwatson
  MFC after:	3 months (set timer; decide then)

Modified:
  head/sys/kern/kern_prot.c
  head/sys/netinet/ip_divert.c
  head/sys/netinet/raw_ip.c
  head/sys/netinet/tcp_subr.c
  head/sys/netinet/udp_usrreq.c
  head/sys/sys/systm.h

Modified: head/sys/kern/kern_prot.c
==============================================================================
--- head/sys/kern/kern_prot.c	Fri Oct 17 16:03:37 2008	(r183981)
+++ head/sys/kern/kern_prot.c	Fri Oct 17 16:26:16 2008	(r183982)
@@ -45,6 +45,8 @@
 __FBSDID("$FreeBSD$");
 
 #include "opt_compat.h"
+#include "opt_inet.h"
+#include "opt_inet6.h"
 #include "opt_mac.h"
 
 #include 
@@ -68,6 +70,11 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#if defined(INET) || defined(INET6)
+#include 
+#include 
+#endif
+
 #include 
 #include 
 
@@ -1704,6 +1711,34 @@ cr_canseesocket(struct ucred *cred, stru
 	return (0);
 }
 
+#if defined(INET) || defined(INET6)
+/*-
+ * Determine whether the subject represented by cred can "see" a socket.
+ * Returns: 0 for permitted, ENOENT otherwise.
+ */
+int
+cr_canseeinpcb(struct ucred *cred, struct inpcb *inp)
+{
+	int error;
+
+	error = prison_check(cred, inp->inp_cred);
+	if (error)
+		return (ENOENT);
+#ifdef MAC
+	INP_LOCK_ASSERT(inp);
+	error = mac_inpcb_check_visible(cred, inp);
+	if (error)
+		return (error);
+#endif
+	if (cr_seeotheruids(cred, inp->inp_cred))
+		return (ENOENT);
+	if (cr_seeothergids(cred, inp->inp_cred))
+		return (ENOENT);
+
+	return (0);
+}
+#endif
+
 /*-
  * Determine whether td can wait for the exit of p.
  * Returns: 0 for permitted, an errno value otherwise

Modified: head/sys/netinet/ip_divert.c
==============================================================================
--- head/sys/netinet/ip_divert.c	Fri Oct 17 16:03:37 2008	(r183981)
+++ head/sys/netinet/ip_divert.c	Fri Oct 17 16:26:16 2008	(r183982)
@@ -627,7 +627,7 @@ div_pcblist(SYSCTL_HANDLER_ARGS)
 	     inp = LIST_NEXT(inp, inp_list)) {
 		INP_RLOCK(inp);
 		if (inp->inp_gencnt <= gencnt &&
-		    cr_canseesocket(req->td->td_ucred, inp->inp_socket) == 0)
+		    cr_canseeinpcb(req->td->td_ucred, inp) == 0)
 			inp_list[i++] = inp;
 		INP_RUNLOCK(inp);
 	}

Modified: head/sys/netinet/raw_ip.c
==============================================================================
--- head/sys/netinet/raw_ip.c	Fri Oct 17 16:03:37 2008	(r183981)
+++ head/sys/netinet/raw_ip.c	Fri Oct 17 16:26:16 2008	(r183982)
@@ -942,7 +942,7 @@ rip_pcblist(SYSCTL_HANDLER_ARGS)
 	     inp = LIST_NEXT(inp, inp_list)) {
 		INP_RLOCK(inp);
 		if (inp->inp_gencnt <= gencnt &&
-		    cr_canseesocket(req->td->td_ucred, inp->inp_socket) == 0) {
+		    cr_canseeinpcb(req->td->td_ucred, inp) == 0) {
 			/* XXX held references? */
 			inp_list[i++] = inp;
 		}

Modified: head/sys/netinet/tcp_subr.c
==============================================================================
--- head/sys/netinet/tcp_subr.c	Fri Oct 17 16:03:37 2008	(r183981)
+++ head/sys/netinet/tcp_subr.c	Fri Oct 17 16:26:16 2008	(r183982)
@@ -1015,8 +1015,7 @@ tcp_pcblist(SYSCTL_HANDLER_ARGS)
 				else
 					error = EINVAL;	/* Skip this inp. */
 			} else
-				error = cr_canseesocket(req->td->td_ucred,
-				    inp->inp_socket);
+				error = cr_canseeinpcb(req->td->td_ucred, inp);
 			if (error == 0)
 				inp_list[i++] = inp;
 		}
@@ -1104,8 +1103,7 @@ tcp_getcred(SYSCTL_HANDLER_ARGS)
 		if (inp->inp_socket == NULL)
 			error = ENOENT;
 		if (error == 0)
-			error = cr_canseesocket(req->td->td_ucred,
-			    inp->inp_socket);
+			error = cr_canseeinpcb(req->td->td_ucred, inp);
 		if (error == 0)
 			cru2x(inp->inp_cred, &xuc);
 		INP_RUNLOCK(inp);
@@ -1168,8 +1166,7 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS)
 		if (inp->inp_socket == NULL)
 			error = ENOENT;
 		if (error == 0)
-			error = cr_canseesocket(req->td->td_ucred,
-			    inp->inp_socket);
+			error = cr_canseeinpcb(req->td->td_ucred, inp);
 		if (error == 0)
 			cru2x(inp->inp_cred, &xuc);
 		INP_RUNLOCK(inp);

Modified: head/sys/netinet/udp_usrreq.c
==============================================================================
--- head/sys/netinet/udp_usrreq.c	Fri Oct 17 16:03:37 2008	(r183981)
+++ head/sys/netinet/udp_usrreq.c	Fri Oct 17 16:26:16 2008	(r183982)
@@ -688,7 +688,7 @@ udp_pcblist(SYSCTL_HANDLER_ARGS)
 	     inp = LIST_NEXT(inp, inp_list)) {
 		INP_RLOCK(inp);
 		if (inp->inp_gencnt <= gencnt &&
-		    cr_canseesocket(req->td->td_ucred, inp->inp_socket) == 0)
+		    cr_canseeinpcb(req->td->td_ucred, inp) == 0)
 			inp_list[i++] = inp;
 		INP_RUNLOCK(inp);
 	}
@@ -758,8 +758,7 @@ udp_getcred(SYSCTL_HANDLER_ARGS)
 		if (inp->inp_socket == NULL)
 			error = ENOENT;
 		if (error == 0)
-			error = cr_canseesocket(req->td->td_ucred,
-			    inp->inp_socket);
+			error = cr_canseeinpcb(req->td->td_ucred, inp);
 		if (error == 0)
 			cru2x(inp->inp_cred, &xuc);
 		INP_RUNLOCK(inp);

Modified: head/sys/sys/systm.h
==============================================================================
--- head/sys/sys/systm.h	Fri Oct 17 16:03:37 2008	(r183981)
+++ head/sys/sys/systm.h	Fri Oct 17 16:26:16 2008	(r183982)
@@ -112,6 +112,7 @@ extern char **kenvp;
  * General function declarations.
  */
 
+struct inpcb;
 struct lock_object;
 struct malloc_type;
 struct mtx;
@@ -227,6 +228,7 @@ void	cpu_stopprofclock(void);
 
 int	cr_cansee(struct ucred *u1, struct ucred *u2);
 int	cr_canseesocket(struct ucred *cred, struct socket *so);
+int	cr_canseeinpcb(struct ucred *cred, struct inpcb *inp);
 
 char	*getenv(const char *name);
 void	freeenv(char *env);
From scottl at samsco.org  Fri Oct 17 18:42:46 2008
From: scottl at samsco.org (Scott Long)
Date: Fri Oct 17 18:43:03 2008
Subject: svn commit: r183981 - head/sys/dev/ata/chipsets
In-Reply-To: <200810171603.m9HG3buK092293@svn.freebsd.org>
References: <200810171603.m9HG3buK092293@svn.freebsd.org>
Message-ID: <20081017123919.C22184@pooker.samsco.org>

On Fri, 17 Oct 2008, John Baldwin wrote:
> Author: jhb
> Date: Fri Oct 17 16:03:37 2008
> New Revision: 183981
> URL: http://svn.freebsd.org/changeset/base/183981
>
> Log:
>  - For chipsets that can't do 64k transfers, fall back to 32k transfers
>    (still a power of 2) rather than 63k transfers.  Even with 63k transfers
>    some machines (such as Dell SC1435's) were experiencing chronic data
>    corruption.

It should be noted that breaking a 64K transfer into two 32K transfers is 
much more ideal than breaking it into a 63k transfer plus a 1k runt. 
Modern drive firmware actually sees the disk internally as 4k sectors now 
instead of 512 byte, so avoiding runt transfers and non-power-of-2 
transfers helps quite a bit with performance.

>  - Use the MIO method to talk to the Serverworks HT1000_S1 SATA controller
>    like all the other SATA controllers rather than the compat PATA
>    method.  This lets the controller see all 4 SATA ports and also
>    matches the behavior of the Linux driver.

Thanks for working on these two issues.

Scott
From delphij at FreeBSD.org  Fri Oct 17 20:09:00 2008
From: delphij at FreeBSD.org (Xin LI)
Date: Fri Oct 17 20:09:12 2008
Subject: svn commit: r183985 - head/lib/libkvm
Message-ID: <200810172009.m9HK90eb096687@svn.freebsd.org>

Author: delphij
Date: Fri Oct 17 20:09:00 2008
New Revision: 183985
URL: http://svn.freebsd.org/changeset/base/183985

Log:
  _kvm_malloc allocates memory through calloc() which
  returns zeroed memory, so don't redo the initialization.

Modified:
  head/lib/libkvm/kvm_minidump_amd64.c
  head/lib/libkvm/kvm_minidump_i386.c

Modified: head/lib/libkvm/kvm_minidump_amd64.c
==============================================================================
--- head/lib/libkvm/kvm_minidump_amd64.c	Fri Oct 17 19:52:35 2008	(r183984)
+++ head/lib/libkvm/kvm_minidump_amd64.c	Fri Oct 17 20:09:00 2008	(r183985)
@@ -146,7 +146,6 @@ _kvm_minidump_initvtop(kvm_t *kd)
 		return (-1);
 	}
 	kd->vmst = vmst;
-	bzero(vmst, sizeof(*vmst));
 	vmst->minidump = 1;
 	if (pread(kd->pmfd, &vmst->hdr, sizeof(vmst->hdr), 0) !=
 	    sizeof(vmst->hdr)) {

Modified: head/lib/libkvm/kvm_minidump_i386.c
==============================================================================
--- head/lib/libkvm/kvm_minidump_i386.c	Fri Oct 17 19:52:35 2008	(r183984)
+++ head/lib/libkvm/kvm_minidump_i386.c	Fri Oct 17 20:09:00 2008	(r183985)
@@ -148,7 +148,6 @@ _kvm_minidump_initvtop(kvm_t *kd)
 		return (-1);
 	}
 	kd->vmst = vmst;
-	bzero(vmst, sizeof(*vmst));
 	vmst->minidump = 1;
 	if (pread(kd->pmfd, &vmst->hdr, sizeof(vmst->hdr), 0) !=
 	    sizeof(vmst->hdr)) {
From delphij at FreeBSD.org  Fri Oct 17 20:11:28 2008
From: delphij at FreeBSD.org (Xin LI)
Date: Fri Oct 17 20:11:40 2008
Subject: svn commit: r183986 - head/lib/libkvm
Message-ID: <200810172011.m9HKBSs7096775@svn.freebsd.org>

Author: delphij
Date: Fri Oct 17 20:11:28 2008
New Revision: 183986
URL: http://svn.freebsd.org/changeset/base/183986

Log:
  Reduce code duplication: use calloc() intead of malloc()
  and memset afterward.

Modified:
  head/lib/libkvm/kvm.c

Modified: head/lib/libkvm/kvm.c
==============================================================================
--- head/lib/libkvm/kvm.c	Fri Oct 17 20:09:00 2008	(r183985)
+++ head/lib/libkvm/kvm.c	Fri Oct 17 20:11:28 2008	(r183986)
@@ -244,11 +244,10 @@ kvm_openfiles(uf, mf, sf, flag, errout)
 {
 	kvm_t *kd;
 
-	if ((kd = malloc(sizeof(*kd))) == NULL) {
+	if ((kd = calloc(1, sizeof(*kd))) == NULL) {
 		(void)strlcpy(errout, strerror(errno), _POSIX2_LINE_MAX);
 		return (0);
 	}
-	memset(kd, 0, sizeof(*kd));
 	kd->program = 0;
 	return (_kvm_open(kd, uf, mf, flag, errout));
 }
@@ -263,13 +262,12 @@ kvm_open(uf, mf, sf, flag, errstr)
 {
 	kvm_t *kd;
 
-	if ((kd = malloc(sizeof(*kd))) == NULL) {
+	if ((kd = calloc(1, sizeof(*kd))) == NULL) {
 		if (errstr != NULL)
 			(void)fprintf(stderr, "%s: %s\n",
 				      errstr, strerror(errno));
 		return (0);
 	}
-	memset(kd, 0, sizeof(*kd));
 	kd->program = errstr;
 	return (_kvm_open(kd, uf, mf, flag, NULL));
 }
From delphij at FreeBSD.org  Fri Oct 17 21:11:09 2008
From: delphij at FreeBSD.org (Xin LI)
Date: Fri Oct 17 21:11:15 2008
Subject: svn commit: r183987 - head/usr.sbin/setfib
Message-ID: <200810172111.m9HLB9A7097897@svn.freebsd.org>

Author: delphij
Date: Fri Oct 17 21:11:09 2008
New Revision: 183987
URL: http://svn.freebsd.org/changeset/base/183987

Log:
   - Use static for usage()
   - Include necessary header files.
  
  setfib(1) should pass WARNS=6 with this changes.

Modified:
  head/usr.sbin/setfib/setfib.c

Modified: head/usr.sbin/setfib/setfib.c
==============================================================================
--- head/usr.sbin/setfib/setfib.c	Fri Oct 17 20:11:28 2008	(r183986)
+++ head/usr.sbin/setfib/setfib.c	Fri Oct 17 21:11:09 2008	(r183987)
@@ -33,15 +33,17 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 
-void usage(void);
+static void usage(void);
 
 int
 main(int argc, char *argv[])
@@ -93,7 +95,7 @@ main(int argc, char *argv[])
 	err(errno == ENOENT ? 127 : 126, "%s", *argv);
 }
 
-void
+static void
 usage(void)
 {
 
From delphij at FreeBSD.org  Fri Oct 17 21:14:51 2008
From: delphij at FreeBSD.org (Xin LI)
Date: Fri Oct 17 21:14:57 2008
Subject: svn commit: r183988 - head/usr.bin/netstat
Message-ID: <200810172114.m9HLEoE2098056@svn.freebsd.org>

Author: delphij
Date: Fri Oct 17 21:14:50 2008
New Revision: 183988
URL: http://svn.freebsd.org/changeset/base/183988

Log:
  Use strlcpy() when we mean it.

Modified:
  head/usr.bin/netstat/inet.c
  head/usr.bin/netstat/route.c

Modified: head/usr.bin/netstat/inet.c
==============================================================================
--- head/usr.bin/netstat/inet.c	Fri Oct 17 21:11:09 2008	(r183987)
+++ head/usr.bin/netstat/inet.c	Fri Oct 17 21:14:50 2008	(r183988)
@@ -1145,8 +1145,7 @@ inetname(struct in_addr *inp)
 	if (inp->s_addr == INADDR_ANY)
 		strcpy(line, "*");
 	else if (cp) {
-		strncpy(line, cp, sizeof(line) - 1);
-		line[sizeof(line) - 1] = '\0';
+		strlcpy(line, cp, sizeof(line));
 	} else {
 		inp->s_addr = ntohl(inp->s_addr);
 #define	C(x)	((u_int)((x) & 0xff))

Modified: head/usr.bin/netstat/route.c
==============================================================================
--- head/usr.bin/netstat/route.c	Fri Oct 17 21:11:09 2008	(r183987)
+++ head/usr.bin/netstat/route.c	Fri Oct 17 21:14:50 2008	(r183988)
@@ -836,8 +836,7 @@ routename(in_addr_t in)
 		}
 	}
 	if (cp) {
-		strncpy(line, cp, sizeof(line) - 1);
-		line[sizeof(line) - 1] = '\0';
+		strlcpy(line, cp, sizeof(line));
 	} else {
 #define	C(x)	((x) & 0xff)
 		in = ntohl(in);
@@ -902,8 +901,7 @@ netname(in_addr_t in, u_long mask)
 		}
 	}
 	if (cp != NULL) {
-		strncpy(line, cp, sizeof(line) - 1);
-		line[sizeof(line) - 1] = '\0';
+		strlcpy(line, cp, sizeof(line));
 	} else {
 		inet_ntop(AF_INET, &in, line, sizeof(line) - 1);
 	}
From delphij at FreeBSD.org  Fri Oct 17 21:21:15 2008
From: delphij at FreeBSD.org (Xin LI)
Date: Fri Oct 17 21:21:26 2008
Subject: svn commit: r183989 - head/lib/libutil
Message-ID: <200810172121.m9HLLETA098194@svn.freebsd.org>

Author: delphij
Date: Fri Oct 17 21:21:14 2008
New Revision: 183989
URL: http://svn.freebsd.org/changeset/base/183989

Log:
  Use strlcpy() when we mean it.

Modified:
  head/lib/libutil/login_times.c
  head/lib/libutil/logwtmp.c
  head/lib/libutil/realhostname.c

Modified: head/lib/libutil/login_times.c
==============================================================================
--- head/lib/libutil/login_times.c	Fri Oct 17 21:14:50 2008	(r183988)
+++ head/lib/libutil/login_times.c	Fri Oct 17 21:21:14 2008	(r183989)
@@ -72,8 +72,7 @@ parse_lt(const char * str)
 	char		buf[64];
 
 	/* Make local copy and force lowercase to simplify parsing */
-	p = strncpy(buf, str, sizeof buf);
-	buf[sizeof buf - 1] = '\0';
+	p = strlcpy(buf, str, sizeof buf);
 	for (i = 0; buf[i]; i++)
 	    buf[i] = (char)tolower(buf[i]);
 

Modified: head/lib/libutil/logwtmp.c
==============================================================================
--- head/lib/libutil/logwtmp.c	Fri Oct 17 21:14:50 2008	(r183988)
+++ head/lib/libutil/logwtmp.c	Fri Oct 17 21:21:14 2008	(r183989)
@@ -59,8 +59,7 @@ logwtmp(const char *line, const char *na
 	char   fullhost[MAXHOSTNAMELEN];
 	int fd;
 	
-	strncpy(fullhost, host, sizeof(fullhost) - 1);	
-	fullhost[sizeof(fullhost) - 1] = '\0';
+	strlcpy(fullhost, host, sizeof(fullhost));	
 	trimdomain(fullhost, UT_HOSTSIZE);
 	host = fullhost;
 

Modified: head/lib/libutil/realhostname.c
==============================================================================
--- head/lib/libutil/realhostname.c	Fri Oct 17 21:14:50 2008	(r183988)
+++ head/lib/libutil/realhostname.c	Fri Oct 17 21:21:14 2008	(r183989)
@@ -61,8 +61,7 @@ realhostname(char *host, size_t hsize, c
 		if (strlen(trimmed) <= hsize) {
 			char lookup[MAXHOSTNAMELEN];
 
-			strncpy(lookup, hp->h_name, sizeof(lookup) - 1);
-			lookup[sizeof(lookup) - 1] = '\0';
+			strlcpy(lookup, hp->h_name, sizeof(lookup));
 			hp = gethostbyname(lookup);
 			if (hp == NULL)
 				result = HOSTNAME_INVALIDNAME;
From delphij at FreeBSD.org  Fri Oct 17 21:29:06 2008
From: delphij at FreeBSD.org (Xin LI)
Date: Fri Oct 17 21:29:17 2008
Subject: svn commit: r183990 - head/lib/libc/string
Message-ID: <200810172129.m9HLT5BT098365@svn.freebsd.org>

Author: delphij
Date: Fri Oct 17 21:29:05 2008
New Revision: 183990
URL: http://svn.freebsd.org/changeset/base/183990

Log:
  Use strlcpy() in !localized case to avoid the -1's.

Modified:
  head/lib/libc/string/strxfrm.c

Modified: head/lib/libc/string/strxfrm.c
==============================================================================
--- head/lib/libc/string/strxfrm.c	Fri Oct 17 21:21:14 2008	(r183989)
+++ head/lib/libc/string/strxfrm.c	Fri Oct 17 21:29:05 2008	(r183990)
@@ -51,8 +51,7 @@ strxfrm(char * __restrict dest, const ch
 			if (slen < len)
 				strcpy(dest, src);
 			else {
-				strncpy(dest, src, len - 1);
-				dest[len - 1] = '\0';
+				strlcpy(dest, src, len);
 			}
 		}
 		return slen;
From bzeeb-lists at lists.zabbadoz.net  Fri Oct 17 22:00:07 2008
From: bzeeb-lists at lists.zabbadoz.net (Bjoern A. Zeeb)
Date: Fri Oct 17 22:00:19 2008
Subject: svn commit: r183922 - in head: share/man/man4 sys/kern sys/sys
In-Reply-To: <200810151658.m9FGwaYZ038854@svn.freebsd.org>
References: <200810151658.m9FGwaYZ038854@svn.freebsd.org>
Message-ID: <20081017215522.O2978@maildrop.int.zabbadoz.net>

On Wed, 15 Oct 2008, Ed Schouten wrote:

> Author: ed
> Date: Wed Oct 15 16:58:35 2008
> New Revision: 183922
> URL: http://svn.freebsd.org/changeset/base/183922
>
> Log:
>  - Change the ddb(4) commands to be more useful (by thompsa@):
>
> Modified:
>  head/share/man/man4/ddb.4
>
> Modified: head/share/man/man4/ddb.4
> ==============================================================================
> --- head/share/man/man4/ddb.4	Wed Oct 15 15:54:33 2008	(r183921)
> +++ head/share/man/man4/ddb.4	Wed Oct 15 16:58:35 2008	(r183922)
> @@ -540,6 +540,13 @@ modifier will alter the display to show
> addresses for the process and not show other information.
> .\"
> .Pp
> +.It Ic show Cm all ttys
> +Show all TTY's within the system.
> +Output is similar to
> +.Xr pstat 8 ,
> +but also includes the address of the TTY structure.
> +.\"
> +.Pp
> .It Ic show Cm allchains
> Show the same information like "show lockchain" does, but
> for every thread in the system.
> @@ -963,10 +970,8 @@ Backtrace.
> .El
> .\"
> .Pp
> -.It Ic show Cm ttys
> -Show all TTY's within the system.
> -Output is similar to
> -.Xr pstat 8 .
> +.It Ic show Cm tty Ar addr
> +Display the contents of a TTY structure in a readable form.
> .\"
> .Pp
> .It Ic show Cm turnstile Ar addr


You should bump the date in there.

-- 
Bjoern A. Zeeb              Stop bit received. Insert coin for new game.
From ed at FreeBSD.org  Sat Oct 18 06:23:08 2008
From: ed at FreeBSD.org (Ed Schouten)
Date: Sat Oct 18 06:23:15 2008
Subject: svn commit: r184018 - head/share/man/man4
Message-ID: <200810180623.m9I6N8Wn008930@svn.freebsd.org>

Author: ed
Date: Sat Oct 18 06:23:08 2008
New Revision: 184018
URL: http://svn.freebsd.org/changeset/base/184018

Log:
  Increase the date in the manual page, which should have been done in r183922.
  
  In r183922 I introduced a new DDB command, documented it, but forgot to
  bump the date in the manual page.
  
  Pointed out by:	bz

Modified:
  head/share/man/man4/ddb.4

Modified: head/share/man/man4/ddb.4
==============================================================================
--- head/share/man/man4/ddb.4	Sat Oct 18 06:20:16 2008	(r184017)
+++ head/share/man/man4/ddb.4	Sat Oct 18 06:23:08 2008	(r184018)
@@ -60,7 +60,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 4, 2008
+.Dd October 18, 2008
 .Dt DDB 4
 .Os
 .Sh NAME
From ed at 80386.nl  Sat Oct 18 06:23:31 2008
From: ed at 80386.nl (Ed Schouten)
Date: Sat Oct 18 06:23:38 2008
Subject: svn commit: r183922 - in head: share/man/man4 sys/kern sys/sys
In-Reply-To: <20081017215522.O2978@maildrop.int.zabbadoz.net>
References: <200810151658.m9FGwaYZ038854@svn.freebsd.org>
	<20081017215522.O2978@maildrop.int.zabbadoz.net>
Message-ID: <20081018062329.GY16837@hoeg.nl>

* Bjoern A. Zeeb  wrote:
> On Wed, 15 Oct 2008, Ed Schouten wrote:
>
>> Author: ed
>> Date: Wed Oct 15 16:58:35 2008
>> New Revision: 183922
>> URL: http://svn.freebsd.org/changeset/base/183922
>>
>> Log:
>>  - Change the ddb(4) commands to be more useful (by thompsa@):
>>
> You should bump the date in there.

Done. Thanks!

-- 
 Ed Schouten 
 WWW: http://80386.nl/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20081018/982598a4/attachment.pgp
From kib at FreeBSD.org  Sat Oct 18 13:39:23 2008
From: kib at FreeBSD.org (Konstantin Belousov)
Date: Sat Oct 18 13:39:29 2008
Subject: svn commit: r184026 - head/sys/amd64/linux32
Message-ID: <200810181339.m9IDdNeQ018119@svn.freebsd.org>

Author: kib
Date: Sat Oct 18 13:39:22 2008
New Revision: 184026
URL: http://svn.freebsd.org/changeset/base/184026

Log:
  Set PCB_32BIT and clear PCB_GS32BIT for linux32 binaries.
  
  Tested by:	dchagin
  MFC after:	3 days

Modified:
  head/sys/amd64/linux32/linux32_sysvec.c

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==============================================================================
--- head/sys/amd64/linux32/linux32_sysvec.c	Sat Oct 18 07:20:45 2008	(r184025)
+++ head/sys/amd64/linux32/linux32_sysvec.c	Sat Oct 18 13:39:22 2008	(r184026)
@@ -843,7 +843,8 @@ exec_linux_setregs(td, entry, stack, ps_
 	fpstate_drop(td);
 
 	/* Return via doreti so that we can change to a different %cs */
-	pcb->pcb_flags |= PCB_FULLCTX;
+	pcb->pcb_flags |= PCB_FULLCTX | PCB_32BIT;
+	pcb->pcb_flags &= ~PCB_GS32BIT;
 	td->td_retval[1] = 0;
 }
 
From rrs at FreeBSD.org  Sat Oct 18 15:53:32 2008
From: rrs at FreeBSD.org (Randall Stewart)
Date: Sat Oct 18 15:53:44 2008
Subject: svn commit: r184027 - head/sys/netinet
Message-ID: <200810181553.m9IFrVi9020443@svn.freebsd.org>

Author: rrs
Date: Sat Oct 18 15:53:31 2008
New Revision: 184027
URL: http://svn.freebsd.org/changeset/base/184027

Log:
  Reported by Yehuda Weinraub (yehudasa@gamil.com) - CRC32C algorithm
  uses incorrect init_bytes value. It SHOULD have the number
  of bytes to get to a 4 byte boundary.
  
  PR:	128134
  MFC after:	4 weeks

Modified:
  head/sys/netinet/sctp_crc32.c

Modified: head/sys/netinet/sctp_crc32.c
==============================================================================
--- head/sys/netinet/sctp_crc32.c	Sat Oct 18 13:39:22 2008	(r184026)
+++ head/sys/netinet/sctp_crc32.c	Sat Oct 18 15:53:31 2008	(r184027)
@@ -583,13 +583,13 @@ update_crc32(uint32_t crc32c,
     unsigned char *buffer,
     unsigned int length)
 {
-	uint32_t offset;
+	uint32_t to_even_word;
 
 	if (length == 0) {
 		return (crc32c);
 	}
-	offset = ((uintptr_t) buffer) & 0x3;
-	return (sctp_crc32c_sb8_64_bit(crc32c, buffer, length, offset));
+	to_even_word = (4 - (((uintptr_t) buffer) & 0x3));
+	return (sctp_crc32c_sb8_64_bit(crc32c, buffer, length, to_even_word));
 }
 
 uint32_t sctp_crc_c[256] = {
From rrs at FreeBSD.org  Sat Oct 18 15:54:25 2008
From: rrs at FreeBSD.org (Randall Stewart)
Date: Sat Oct 18 15:54:37 2008
Subject: svn commit: r184028 - head/sys/netinet
Message-ID: <200810181554.m9IFsPoI020497@svn.freebsd.org>

Author: rrs
Date: Sat Oct 18 15:54:25 2008
New Revision: 184028
URL: http://svn.freebsd.org/changeset/base/184028

Log:
  - Adapt layer indication was always being given (it should only
    be given when the user has enabled it). (Michael Tuexen)
  - Sack Immediately was not being set properly on the actual chunk, it
    was only put in the rcvd_flags which is incorrect. (Michael Tuexen)
  - added an ifndef userspace to one of the already present macro's for
    inet (Brad Penoff)
  Obtained from:	Michael Tuexen and Brad Penoff
  MFC after:	4 weeks

Modified:
  head/sys/netinet/sctp_output.c

Modified: head/sys/netinet/sctp_output.c
==============================================================================
--- head/sys/netinet/sctp_output.c	Sat Oct 18 15:53:31 2008	(r184027)
+++ head/sys/netinet/sctp_output.c	Sat Oct 18 15:54:25 2008	(r184028)
@@ -4096,6 +4096,7 @@ sctp_send_initiate(struct sctp_inpcb *in
 	struct sctp_nets *net;
 	struct sctp_init_msg *initm;
 	struct sctp_supported_addr_param *sup_addr;
+	struct sctp_adaptation_layer_indication *ali;
 	struct sctp_ecn_supported_param *ecn;
 	struct sctp_prsctp_supported_param *prsctp;
 	struct sctp_ecn_nonce_supported_param *ecn_nonce;
@@ -4193,21 +4194,13 @@ sctp_send_initiate(struct sctp_inpcb *in
 #endif
 	SCTP_BUF_LEN(m) += sizeof(*sup_addr) + sizeof(uint16_t);
 
-	if (inp->sctp_ep.adaptation_layer_indicator) {
-		struct sctp_adaptation_layer_indication *ali;
-
-		ali = (struct sctp_adaptation_layer_indication *)(
-		    (caddr_t)sup_addr + sizeof(*sup_addr) + sizeof(uint16_t));
-		ali->ph.param_type = htons(SCTP_ULP_ADAPTATION);
-		ali->ph.param_length = htons(sizeof(*ali));
-		ali->indication = ntohl(inp->sctp_ep.adaptation_layer_indicator);
-		SCTP_BUF_LEN(m) += sizeof(*ali);
-		ecn = (struct sctp_ecn_supported_param *)((caddr_t)ali +
-		    sizeof(*ali));
-	} else {
-		ecn = (struct sctp_ecn_supported_param *)((caddr_t)sup_addr +
-		    sizeof(*sup_addr) + sizeof(uint16_t));
-	}
+	/* adaptation layer indication parameter */
+	ali = (struct sctp_adaptation_layer_indication *)((caddr_t)sup_addr + sizeof(*sup_addr) + sizeof(uint16_t));
+	ali->ph.param_type = htons(SCTP_ULP_ADAPTATION);
+	ali->ph.param_length = htons(sizeof(*ali));
+	ali->indication = ntohl(inp->sctp_ep.adaptation_layer_indicator);
+	SCTP_BUF_LEN(m) += sizeof(*ali);
+	ecn = (struct sctp_ecn_supported_param *)((caddr_t)ali + sizeof(*ali));
 
 	/* now any cookie time extensions */
 	if (stcb->asoc.cookie_preserve_req) {
@@ -4889,6 +4882,7 @@ sctp_send_initiate_ack(struct sctp_inpcb
 	struct sctp_association *asoc;
 	struct mbuf *m, *m_at, *m_tmp, *m_cookie, *op_err, *mp_last;
 	struct sctp_init_msg *initackm_out;
+	struct sctp_adaptation_layer_indication *ali;
 	struct sctp_ecn_supported_param *ecn;
 	struct sctp_prsctp_supported_param *prsctp;
 	struct sctp_ecn_nonce_supported_param *ecn_nonce;
@@ -5319,23 +5313,14 @@ do_a_abort:
 	/* tell him his limt. */
 	initackm_out->msg.init.num_inbound_streams =
 	    htons(inp->sctp_ep.max_open_streams_intome);
-	/* setup the ECN pointer */
 
-	if (inp->sctp_ep.adaptation_layer_indicator) {
-		struct sctp_adaptation_layer_indication *ali;
-
-		ali = (struct sctp_adaptation_layer_indication *)(
-		    (caddr_t)initackm_out + sizeof(*initackm_out));
-		ali->ph.param_type = htons(SCTP_ULP_ADAPTATION);
-		ali->ph.param_length = htons(sizeof(*ali));
-		ali->indication = ntohl(inp->sctp_ep.adaptation_layer_indicator);
-		SCTP_BUF_LEN(m) += sizeof(*ali);
-		ecn = (struct sctp_ecn_supported_param *)((caddr_t)ali +
-		    sizeof(*ali));
-	} else {
-		ecn = (struct sctp_ecn_supported_param *)(
-		    (caddr_t)initackm_out + sizeof(*initackm_out));
-	}
+	/* adaptation layer indication parameter */
+	ali = (struct sctp_adaptation_layer_indication *)((caddr_t)initackm_out + sizeof(*initackm_out));
+	ali->ph.param_type = htons(SCTP_ULP_ADAPTATION);
+	ali->ph.param_length = htons(sizeof(*ali));
+	ali->indication = ntohl(inp->sctp_ep.adaptation_layer_indicator);
+	SCTP_BUF_LEN(m) += sizeof(*ali);
+	ecn = (struct sctp_ecn_supported_param *)((caddr_t)ali + sizeof(*ali));
 
 	/* ECN parameter */
 	if (SCTP_BASE_SYSCTL(sctp_ecn_enable) == 1) {
@@ -6816,6 +6801,9 @@ re_look:
 	if (sp->sinfo_flags & SCTP_UNORDERED) {
 		rcv_flags |= SCTP_DATA_UNORDERED;
 	}
+	if (SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) && ((sp->sinfo_flags & SCTP_EOF) == SCTP_EOF)) {
+		rcv_flags |= SCTP_DATA_SACK_IMMEDIATELY;
+	}
 	/* clear out the chunk before setting up */
 	memset(chk, 0, sizeof(*chk));
 	chk->rec.data.rcv_flags = rcv_flags;
@@ -8062,6 +8050,13 @@ again_one_more_time:
 					    chk->send_size, mtu);
 					chk->flags |= CHUNK_FLAGS_FRAGMENT_OK;
 				}
+				if (SCTP_BASE_SYSCTL(sctp_enable_sack_immediately) &&
+				    ((asoc->state & SCTP_STATE_SHUTDOWN_PENDING) == SCTP_STATE_SHUTDOWN_PENDING)) {
+					struct sctp_data_chunk *dchkh;
+
+					dchkh = mtod(chk->data, struct sctp_data_chunk *);
+					dchkh->ch.chunk_flags |= SCTP_DATA_SACK_IMMEDIATELY;
+				}
 				if (((chk->send_size <= mtu) && (chk->send_size <= r_mtu)) ||
 				    ((chk->flags & CHUNK_FLAGS_FRAGMENT_OK) && (chk->send_size <= asoc->peers_rwnd))) {
 					/* ok we will add this one */
@@ -11737,7 +11732,7 @@ sctp_sosend(struct socket *so,
 		}
 	}
 	addr_to_use = addr;
-#ifdef INET6
+#if defined(INET6)  && !defined(__Userspace__)	/* TODO port in6_sin6_2_sin */
 	if ((addr) && (addr->sa_family == AF_INET6)) {
 		struct sockaddr_in6 *sin6;
 
From rrs at FreeBSD.org  Sat Oct 18 15:55:16 2008
From: rrs at FreeBSD.org (Randall Stewart)
Date: Sat Oct 18 15:55:28 2008
Subject: svn commit: r184029 - head/sys/netinet
Message-ID: <200810181555.m9IFtGKG020564@svn.freebsd.org>

Author: rrs
Date: Sat Oct 18 15:55:15 2008
New Revision: 184029
URL: http://svn.freebsd.org/changeset/base/184029

Log:
  - Peers rwnd is now available for the MIB.
  Obtained from:	Michael Tuexen

Modified:
  head/sys/netinet/sctp_sysctl.c
  head/sys/netinet/sctp_uio.h

Modified: head/sys/netinet/sctp_sysctl.c
==============================================================================
--- head/sys/netinet/sctp_sysctl.c	Sat Oct 18 15:54:25 2008	(r184028)
+++ head/sys/netinet/sctp_sysctl.c	Sat Oct 18 15:55:15 2008	(r184029)
@@ -426,6 +426,7 @@ sctp_assoclist(SYSCTL_HANDLER_ARGS)
 			xstcb.cumulative_tsn = stcb->asoc.last_acked_seq;
 			xstcb.cumulative_tsn_ack = stcb->asoc.cumulative_tsn;
 			xstcb.mtu = stcb->asoc.smallest_mtu;
+			xstcb.peers_rwnd = stcb->asoc.peers_rwnd;
 			xstcb.refcnt = stcb->asoc.refcnt;
 			SCTP_INP_RUNLOCK(inp);
 			SCTP_INP_INFO_RUNLOCK();

Modified: head/sys/netinet/sctp_uio.h
==============================================================================
--- head/sys/netinet/sctp_uio.h	Sat Oct 18 15:54:25 2008	(r184028)
+++ head/sys/netinet/sctp_uio.h	Sat Oct 18 15:55:15 2008	(r184029)
@@ -989,6 +989,7 @@ struct xsctp_tcb {
 	uint32_t cumulative_tsn;
 	uint32_t cumulative_tsn_ack;
 	uint32_t mtu;
+	uint32_t peers_rwnd;
 	uint32_t refcnt;
 	uint16_t local_port;	/* sctpAssocEntry 3   */
 	uint16_t remote_port;	/* sctpAssocEntry 4   */
From rrs at FreeBSD.org  Sat Oct 18 15:56:12 2008
From: rrs at FreeBSD.org (Randall Stewart)
Date: Sat Oct 18 15:56:19 2008
Subject: svn commit: r184030 - head/sys/netinet
Message-ID: <200810181556.m9IFuCpt020617@svn.freebsd.org>

Author: rrs
Date: Sat Oct 18 15:56:12 2008
New Revision: 184030
URL: http://svn.freebsd.org/changeset/base/184030

Log:
  New sockets (accepted) were not inheriting the proper snd/rcv buffer value.
  
  Obtained from:	 Michael Tuexen

Modified:
  head/sys/netinet/sctp_usrreq.c

Modified: head/sys/netinet/sctp_usrreq.c
==============================================================================
--- head/sys/netinet/sctp_usrreq.c	Sat Oct 18 15:55:15 2008	(r184029)
+++ head/sys/netinet/sctp_usrreq.c	Sat Oct 18 15:56:12 2008	(r184030)
@@ -517,9 +517,11 @@ sctp_attach(struct socket *so, int proto
 		SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
 		return EINVAL;
 	}
-	error = SCTP_SORESERVE(so, SCTP_BASE_SYSCTL(sctp_sendspace), SCTP_BASE_SYSCTL(sctp_recvspace));
-	if (error) {
-		return error;
+	if (so->so_snd.sb_hiwat == 0 || so->so_rcv.sb_hiwat == 0) {
+		error = SCTP_SORESERVE(so, SCTP_BASE_SYSCTL(sctp_sendspace), SCTP_BASE_SYSCTL(sctp_recvspace));
+		if (error) {
+			return error;
+		}
 	}
 	error = sctp_inpcb_alloc(so, vrf_id);
 	if (error) {
From rrs at FreeBSD.org  Sat Oct 18 15:56:53 2008
From: rrs at FreeBSD.org (Randall Stewart)
Date: Sat Oct 18 15:56:59 2008
Subject: svn commit: r184031 - head/sys/netinet
Message-ID: <200810181556.m9IFurli020662@svn.freebsd.org>

Author: rrs
Date: Sat Oct 18 15:56:52 2008
New Revision: 184031
URL: http://svn.freebsd.org/changeset/base/184031

Log:
  The flags value was not always being copied out in the recv routine like it
  should be.
  Obtained from:	Michael Tuexen

Modified:
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctputil.c
==============================================================================
--- head/sys/netinet/sctputil.c	Sat Oct 18 15:56:12 2008	(r184030)
+++ head/sys/netinet/sctputil.c	Sat Oct 18 15:56:52 2008	(r184031)
@@ -5896,9 +5896,10 @@ release_unlocked:
 		    (no_rcv_needed == 0))
 			sctp_user_rcvd(stcb, &freed_so_far, hold_rlock, rwnd_req);
 	}
-	if (msg_flags)
-		*msg_flags = out_flags;
 out:
+	if (msg_flags) {
+		*msg_flags = out_flags;
+	}
 	if (((out_flags & MSG_EOR) == 0) &&
 	    ((in_flags & MSG_PEEK) == 0) &&
 	    (sinfo) &&
From mav at FreeBSD.org  Sat Oct 18 16:17:04 2008
From: mav at FreeBSD.org (Alexander Motin)
Date: Sat Oct 18 16:17:17 2008
Subject: svn commit: r184033 - head/sys/dev/mmc
Message-ID: <200810181617.m9IGH4m8021093@svn.freebsd.org>

Author: mav
Date: Sat Oct 18 16:17:04 2008
New Revision: 184033
URL: http://svn.freebsd.org/changeset/base/184033

Log:
  Implement BIO_DELETE command with MMC and SD erase commands.
  
  Erase operation gives card's logic information about unused areas to help it
  implement wear-leveling with lower overhead comparing to usual writing.
  Erase is much faster then write and does not depends on data bus speed.
  Also as result of hitting in-card write logic optimizations I have measured
  up to 50% performance boost on writing undersized blocks into preerased areas.
  
  At the same time there are strict limitations on size and allignment of erase
  operations. We can erase only blocks aligned to the erase sector size and
  with size multiple of it. Different cards has different erase sector size
  which usually varies from 64KB to 4MB. SD cards actually allow to erase
  smaller blocks, but it is much more expensive as it is implemented via
  read-erase-write sequence and so not sutable for the BIO_DELETE purposes.
  
  Reviewed by:	imp@

Modified:
  head/sys/dev/mmc/mmc.c
  head/sys/dev/mmc/mmcreg.h
  head/sys/dev/mmc/mmcsd.c
  head/sys/dev/mmc/mmcvar.h

Modified: head/sys/dev/mmc/mmc.c
==============================================================================
--- head/sys/dev/mmc/mmc.c	Sat Oct 18 16:02:48 2008	(r184032)
+++ head/sys/dev/mmc/mmc.c	Sat Oct 18 16:17:04 2008	(r184033)
@@ -85,11 +85,13 @@ struct mmc_ivars {
 	uint32_t raw_csd[4];	/* Raw bits of the CSD */
 	uint32_t raw_scr[2];	/* Raw bits of the SCR */
 	uint8_t raw_ext_csd[512];	/* Raw bits of the EXT_CSD */
+	uint32_t raw_sd_status[16];	/* Raw bits of the SD_STATUS */
 	uint16_t rca;
 	enum mmc_card_mode mode;
 	struct mmc_cid cid;	/* cid decoded */
 	struct mmc_csd csd;	/* csd decoded */
 	struct mmc_scr scr;	/* scr decoded */
+	struct mmc_sd_status sd_status;	/* SD_STATUS decoded */
 	u_char read_only;	/* True when the device is read-only */
 	u_char bus_width;	/* Bus width to use */
 	u_char timing;		/* Bus timing support */
@@ -97,6 +99,7 @@ struct mmc_ivars {
 	uint32_t sec_count;	/* Card capacity in 512byte blocks */
 	uint32_t tran_speed;	/* Max speed in normal mode */
 	uint32_t hs_tran_speed;	/* Max speed in high speed mode */
+	uint32_t erase_sector;	/* Card native erase sector size */
 };
 
 #define CMD_RETRIES	3
@@ -723,9 +726,8 @@ mmc_test_bus_width(struct mmc_softc *sc)
 }
 
 static uint32_t
-mmc_get_bits(uint32_t *bits, int start, int size)
+mmc_get_bits(uint32_t *bits, int bit_len, int start, int size)
 {
-	const int bit_len = 128;
 	const int i = (bit_len / 32) - (start / 32) - 1;
 	const int shift = start & 31;
 	uint32_t retval = bits[i] >> shift;
@@ -741,14 +743,14 @@ mmc_decode_cid_sd(uint32_t *raw_cid, str
 
 	/* There's no version info, so we take it on faith */
 	memset(cid, 0, sizeof(*cid));
-	cid->mid = mmc_get_bits(raw_cid, 120, 8);
-	cid->oid = mmc_get_bits(raw_cid, 104, 16);
+	cid->mid = mmc_get_bits(raw_cid, 128, 120, 8);
+	cid->oid = mmc_get_bits(raw_cid, 128, 104, 16);
 	for (i = 0; i < 5; i++)
-		cid->pnm[i] = mmc_get_bits(raw_cid, 96 - i * 8, 8);
-	cid->prv = mmc_get_bits(raw_cid, 56, 8);
-	cid->psn = mmc_get_bits(raw_cid, 24, 32);
-	cid->mdt_year = mmc_get_bits(raw_cid, 12, 8) + 2001;
-	cid->mdt_month = mmc_get_bits(raw_cid, 8, 4);
+		cid->pnm[i] = mmc_get_bits(raw_cid, 128, 96 - i * 8, 8);
+	cid->prv = mmc_get_bits(raw_cid, 128, 56, 8);
+	cid->psn = mmc_get_bits(raw_cid, 128, 24, 32);
+	cid->mdt_year = mmc_get_bits(raw_cid, 128, 12, 8) + 2001;
+	cid->mdt_month = mmc_get_bits(raw_cid, 128, 8, 4);
 }
 
 static void
@@ -758,14 +760,14 @@ mmc_decode_cid_mmc(uint32_t *raw_cid, st
 
 	/* There's no version info, so we take it on faith */
 	memset(cid, 0, sizeof(*cid));
-	cid->mid = mmc_get_bits(raw_cid, 120, 8);
-	cid->oid = mmc_get_bits(raw_cid, 104, 8);
+	cid->mid = mmc_get_bits(raw_cid, 128, 120, 8);
+	cid->oid = mmc_get_bits(raw_cid, 128, 104, 8);
 	for (i = 0; i < 6; i++)
-		cid->pnm[i] = mmc_get_bits(raw_cid, 96 - i * 8, 8);
-	cid->prv = mmc_get_bits(raw_cid, 48, 8);
-	cid->psn = mmc_get_bits(raw_cid, 16, 32);
-	cid->mdt_month = mmc_get_bits(raw_cid, 12, 4);
-	cid->mdt_year = mmc_get_bits(raw_cid, 8, 4) + 1997;
+		cid->pnm[i] = mmc_get_bits(raw_cid, 128, 96 - i * 8, 8);
+	cid->prv = mmc_get_bits(raw_cid, 128, 48, 8);
+	cid->psn = mmc_get_bits(raw_cid, 128, 16, 32);
+	cid->mdt_month = mmc_get_bits(raw_cid, 128, 12, 4);
+	cid->mdt_year = mmc_get_bits(raw_cid, 128, 8, 4) + 1997;
 }
 
 static const int exp[8] = {
@@ -789,58 +791,58 @@ mmc_decode_csd_sd(uint32_t *raw_csd, str
 	int e;
 
 	memset(csd, 0, sizeof(*csd));
-	csd->csd_structure = v = mmc_get_bits(raw_csd, 126, 2);
+	csd->csd_structure = v = mmc_get_bits(raw_csd, 128, 126, 2);
 	if (v == 0) {
-		m = mmc_get_bits(raw_csd, 115, 4);
-		e = mmc_get_bits(raw_csd, 112, 3);
+		m = mmc_get_bits(raw_csd, 128, 115, 4);
+		e = mmc_get_bits(raw_csd, 128, 112, 3);
 		csd->tacc = exp[e] * mant[m] + 9 / 10;
-		csd->nsac = mmc_get_bits(raw_csd, 104, 8) * 100;
-		m = mmc_get_bits(raw_csd, 99, 4);
-		e = mmc_get_bits(raw_csd, 96, 3);
+		csd->nsac = mmc_get_bits(raw_csd, 128, 104, 8) * 100;
+		m = mmc_get_bits(raw_csd, 128, 99, 4);
+		e = mmc_get_bits(raw_csd, 128, 96, 3);
 		csd->tran_speed = exp[e] * 10000 * mant[m];
-		csd->ccc = mmc_get_bits(raw_csd, 84, 12);
-		csd->read_bl_len = 1 << mmc_get_bits(raw_csd, 80, 4);
-		csd->read_bl_partial = mmc_get_bits(raw_csd, 79, 1);
-		csd->write_blk_misalign = mmc_get_bits(raw_csd, 78, 1);
-		csd->read_blk_misalign = mmc_get_bits(raw_csd, 77, 1);
-		csd->dsr_imp = mmc_get_bits(raw_csd, 76, 1);
-		csd->vdd_r_curr_min = cur_min[mmc_get_bits(raw_csd, 59, 3)];
-		csd->vdd_r_curr_max = cur_max[mmc_get_bits(raw_csd, 56, 3)];
-		csd->vdd_w_curr_min = cur_min[mmc_get_bits(raw_csd, 53, 3)];
-		csd->vdd_w_curr_max = cur_max[mmc_get_bits(raw_csd, 50, 3)];
-		m = mmc_get_bits(raw_csd, 62, 12);
-		e = mmc_get_bits(raw_csd, 47, 3);
+		csd->ccc = mmc_get_bits(raw_csd, 128, 84, 12);
+		csd->read_bl_len = 1 << mmc_get_bits(raw_csd, 128, 80, 4);
+		csd->read_bl_partial = mmc_get_bits(raw_csd, 128, 79, 1);
+		csd->write_blk_misalign = mmc_get_bits(raw_csd, 128, 78, 1);
+		csd->read_blk_misalign = mmc_get_bits(raw_csd, 128, 77, 1);
+		csd->dsr_imp = mmc_get_bits(raw_csd, 128, 76, 1);
+		csd->vdd_r_curr_min = cur_min[mmc_get_bits(raw_csd, 128, 59, 3)];
+		csd->vdd_r_curr_max = cur_max[mmc_get_bits(raw_csd, 128, 56, 3)];
+		csd->vdd_w_curr_min = cur_min[mmc_get_bits(raw_csd, 128, 53, 3)];
+		csd->vdd_w_curr_max = cur_max[mmc_get_bits(raw_csd, 128, 50, 3)];
+		m = mmc_get_bits(raw_csd, 128, 62, 12);
+		e = mmc_get_bits(raw_csd, 128, 47, 3);
 		csd->capacity = ((1 + m) << (e + 2)) * csd->read_bl_len;
-		csd->erase_blk_en = mmc_get_bits(raw_csd, 46, 1);
-		csd->sector_size = mmc_get_bits(raw_csd, 39, 7);
-		csd->wp_grp_size = mmc_get_bits(raw_csd, 32, 7);
-		csd->wp_grp_enable = mmc_get_bits(raw_csd, 31, 1);
-		csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 26, 3);
-		csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 22, 4);
-		csd->write_bl_partial = mmc_get_bits(raw_csd, 21, 1);
+		csd->erase_blk_en = mmc_get_bits(raw_csd, 128, 46, 1);
+		csd->erase_sector = mmc_get_bits(raw_csd, 128, 39, 7) + 1;
+		csd->wp_grp_size = mmc_get_bits(raw_csd, 128, 32, 7);
+		csd->wp_grp_enable = mmc_get_bits(raw_csd, 128, 31, 1);
+		csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 128, 26, 3);
+		csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 128, 22, 4);
+		csd->write_bl_partial = mmc_get_bits(raw_csd, 128, 21, 1);
 	} else if (v == 1) {
-		m = mmc_get_bits(raw_csd, 115, 4);
-		e = mmc_get_bits(raw_csd, 112, 3);
+		m = mmc_get_bits(raw_csd, 128, 115, 4);
+		e = mmc_get_bits(raw_csd, 128, 112, 3);
 		csd->tacc = exp[e] * mant[m] + 9 / 10;
-		csd->nsac = mmc_get_bits(raw_csd, 104, 8) * 100;
-		m = mmc_get_bits(raw_csd, 99, 4);
-		e = mmc_get_bits(raw_csd, 96, 3);
+		csd->nsac = mmc_get_bits(raw_csd, 128, 104, 8) * 100;
+		m = mmc_get_bits(raw_csd, 128, 99, 4);
+		e = mmc_get_bits(raw_csd, 128, 96, 3);
 		csd->tran_speed = exp[e] * 10000 * mant[m];
-		csd->ccc = mmc_get_bits(raw_csd, 84, 12);
-		csd->read_bl_len = 1 << mmc_get_bits(raw_csd, 80, 4);
-		csd->read_bl_partial = mmc_get_bits(raw_csd, 79, 1);
-		csd->write_blk_misalign = mmc_get_bits(raw_csd, 78, 1);
-		csd->read_blk_misalign = mmc_get_bits(raw_csd, 77, 1);
-		csd->dsr_imp = mmc_get_bits(raw_csd, 76, 1);
-		csd->capacity = ((uint64_t)mmc_get_bits(raw_csd, 48, 22) + 1) *
+		csd->ccc = mmc_get_bits(raw_csd, 128, 84, 12);
+		csd->read_bl_len = 1 << mmc_get_bits(raw_csd, 128, 80, 4);
+		csd->read_bl_partial = mmc_get_bits(raw_csd, 128, 79, 1);
+		csd->write_blk_misalign = mmc_get_bits(raw_csd, 128, 78, 1);
+		csd->read_blk_misalign = mmc_get_bits(raw_csd, 128, 77, 1);
+		csd->dsr_imp = mmc_get_bits(raw_csd, 128, 76, 1);
+		csd->capacity = ((uint64_t)mmc_get_bits(raw_csd, 128, 48, 22) + 1) *
 		    512 * 1024;
-		csd->erase_blk_en = mmc_get_bits(raw_csd, 46, 1);
-		csd->sector_size = mmc_get_bits(raw_csd, 39, 7);
-		csd->wp_grp_size = mmc_get_bits(raw_csd, 32, 7);
-		csd->wp_grp_enable = mmc_get_bits(raw_csd, 31, 1);
-		csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 26, 3);
-		csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 22, 4);
-		csd->write_bl_partial = mmc_get_bits(raw_csd, 21, 1);
+		csd->erase_blk_en = mmc_get_bits(raw_csd, 128, 46, 1);
+		csd->erase_sector = mmc_get_bits(raw_csd, 128, 39, 7) + 1;
+		csd->wp_grp_size = mmc_get_bits(raw_csd, 128, 32, 7);
+		csd->wp_grp_enable = mmc_get_bits(raw_csd, 128, 31, 1);
+		csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 128, 26, 3);
+		csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 128, 22, 4);
+		csd->write_bl_partial = mmc_get_bits(raw_csd, 128, 21, 1);
 	} else 
 		panic("unknown SD CSD version");
 }
@@ -852,56 +854,72 @@ mmc_decode_csd_mmc(uint32_t *raw_csd, st
 	int e;
 
 	memset(csd, 0, sizeof(*csd));
-	csd->csd_structure = mmc_get_bits(raw_csd, 126, 2);
-	csd->spec_vers = mmc_get_bits(raw_csd, 122, 4);
-	m = mmc_get_bits(raw_csd, 115, 4);
-	e = mmc_get_bits(raw_csd, 112, 3);
+	csd->csd_structure = mmc_get_bits(raw_csd, 128, 126, 2);
+	csd->spec_vers = mmc_get_bits(raw_csd, 128, 122, 4);
+	m = mmc_get_bits(raw_csd, 128, 115, 4);
+	e = mmc_get_bits(raw_csd, 128, 112, 3);
 	csd->tacc = exp[e] * mant[m] + 9 / 10;
-	csd->nsac = mmc_get_bits(raw_csd, 104, 8) * 100;
-	m = mmc_get_bits(raw_csd, 99, 4);
-	e = mmc_get_bits(raw_csd, 96, 3);
+	csd->nsac = mmc_get_bits(raw_csd, 128, 104, 8) * 100;
+	m = mmc_get_bits(raw_csd, 128, 99, 4);
+	e = mmc_get_bits(raw_csd, 128, 96, 3);
 	csd->tran_speed = exp[e] * 10000 * mant[m];
-	csd->ccc = mmc_get_bits(raw_csd, 84, 12);
-	csd->read_bl_len = 1 << mmc_get_bits(raw_csd, 80, 4);
-	csd->read_bl_partial = mmc_get_bits(raw_csd, 79, 1);
-	csd->write_blk_misalign = mmc_get_bits(raw_csd, 78, 1);
-	csd->read_blk_misalign = mmc_get_bits(raw_csd, 77, 1);
-	csd->dsr_imp = mmc_get_bits(raw_csd, 76, 1);
-	csd->vdd_r_curr_min = cur_min[mmc_get_bits(raw_csd, 59, 3)];
-	csd->vdd_r_curr_max = cur_max[mmc_get_bits(raw_csd, 56, 3)];
-	csd->vdd_w_curr_min = cur_min[mmc_get_bits(raw_csd, 53, 3)];
-	csd->vdd_w_curr_max = cur_max[mmc_get_bits(raw_csd, 50, 3)];
-	m = mmc_get_bits(raw_csd, 62, 12);
-	e = mmc_get_bits(raw_csd, 47, 3);
+	csd->ccc = mmc_get_bits(raw_csd, 128, 84, 12);
+	csd->read_bl_len = 1 << mmc_get_bits(raw_csd, 128, 80, 4);
+	csd->read_bl_partial = mmc_get_bits(raw_csd, 128, 79, 1);
+	csd->write_blk_misalign = mmc_get_bits(raw_csd, 128, 78, 1);
+	csd->read_blk_misalign = mmc_get_bits(raw_csd, 128, 77, 1);
+	csd->dsr_imp = mmc_get_bits(raw_csd, 128, 76, 1);
+	csd->vdd_r_curr_min = cur_min[mmc_get_bits(raw_csd, 128, 59, 3)];
+	csd->vdd_r_curr_max = cur_max[mmc_get_bits(raw_csd, 128, 56, 3)];
+	csd->vdd_w_curr_min = cur_min[mmc_get_bits(raw_csd, 128, 53, 3)];
+	csd->vdd_w_curr_max = cur_max[mmc_get_bits(raw_csd, 128, 50, 3)];
+	m = mmc_get_bits(raw_csd, 128, 62, 12);
+	e = mmc_get_bits(raw_csd, 128, 47, 3);
 	csd->capacity = ((1 + m) << (e + 2)) * csd->read_bl_len;
-//	csd->erase_blk_en = mmc_get_bits(raw_csd, 46, 1);
-//	csd->sector_size = mmc_get_bits(raw_csd, 39, 7);
-	csd->wp_grp_size = mmc_get_bits(raw_csd, 32, 5);
-	csd->wp_grp_enable = mmc_get_bits(raw_csd, 31, 1);
-	csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 26, 3);
-	csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 22, 4);
-	csd->write_bl_partial = mmc_get_bits(raw_csd, 21, 1);
+	csd->erase_blk_en = 0;
+	csd->erase_sector = (mmc_get_bits(raw_csd, 128, 42, 5) + 1) *
+	    (mmc_get_bits(raw_csd, 128, 37, 5) + 1);
+	csd->wp_grp_size = mmc_get_bits(raw_csd, 128, 32, 5);
+	csd->wp_grp_enable = mmc_get_bits(raw_csd, 128, 31, 1);
+	csd->r2w_factor = 1 << mmc_get_bits(raw_csd, 128, 26, 3);
+	csd->write_bl_len = 1 << mmc_get_bits(raw_csd, 128, 22, 4);
+	csd->write_bl_partial = mmc_get_bits(raw_csd, 128, 21, 1);
 }
 
 static void
 mmc_app_decode_scr(uint32_t *raw_scr, struct mmc_scr *scr)
 {
 	unsigned int scr_struct;
-	uint32_t tmp[4];
-
-	tmp[3] = raw_scr[1];
-	tmp[2] = raw_scr[0];
 
 	memset(scr, 0, sizeof(*scr));
 
-	scr_struct = mmc_get_bits(tmp, 60, 4);
+	scr_struct = mmc_get_bits(raw_scr, 64, 60, 4);
 	if (scr_struct != 0) {
 		printf("Unrecognised SCR structure version %d\n",
 		    scr_struct);
 		return;
 	}
-	scr->sda_vsn = mmc_get_bits(tmp, 56, 4);
-	scr->bus_widths = mmc_get_bits(tmp, 48, 4);
+	scr->sda_vsn = mmc_get_bits(raw_scr, 64, 56, 4);
+	scr->bus_widths = mmc_get_bits(raw_scr, 64, 48, 4);
+}
+
+static void
+mmc_app_decode_sd_status(uint32_t *raw_sd_status,
+    struct mmc_sd_status *sd_status)
+{
+
+	memset(sd_status, 0, sizeof(*sd_status));
+
+	sd_status->bus_width = mmc_get_bits(raw_sd_status, 512, 510, 2);
+	sd_status->secured_mode = mmc_get_bits(raw_sd_status, 512, 509, 1);
+	sd_status->card_type = mmc_get_bits(raw_sd_status, 512, 480, 16);
+	sd_status->prot_area = mmc_get_bits(raw_sd_status, 512, 448, 12);
+	sd_status->speed_class = mmc_get_bits(raw_sd_status, 512, 440, 8);
+	sd_status->perf_move = mmc_get_bits(raw_sd_status, 512, 432, 8);
+	sd_status->au_size = mmc_get_bits(raw_sd_status, 512, 428, 4);
+	sd_status->erase_size = mmc_get_bits(raw_sd_status, 512, 408, 16);
+	sd_status->erase_timeout = mmc_get_bits(raw_sd_status, 512, 402, 6);
+	sd_status->erase_offset = mmc_get_bits(raw_sd_status, 512, 400, 2);
 }
 
 static int
@@ -985,6 +1003,32 @@ mmc_send_ext_csd(struct mmc_softc *sc, u
 }
 
 static int
+mmc_app_sd_status(struct mmc_softc *sc, uint16_t rca, uint32_t *rawsdstatus)
+{
+	int err, i;
+	struct mmc_command cmd;
+	struct mmc_data data;
+
+	memset(&cmd, 0, sizeof(struct mmc_command));
+	memset(&data, 0, sizeof(struct mmc_data));
+
+	memset(rawsdstatus, 0, 64);
+	cmd.opcode = ACMD_SD_STATUS;
+	cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
+	cmd.arg = 0;
+	cmd.data = &data;
+
+	data.data = rawsdstatus;
+	data.len = 64;
+	data.flags = MMC_DATA_READ;
+
+	err = mmc_wait_for_app_cmd(sc, rca, &cmd, CMD_RETRIES);
+	for (i = 0; i < 16; i++)
+	    rawsdstatus[i] = be32toh(rawsdstatus[i]);
+	return (err);
+}
+
+static int
 mmc_set_relative_addr(struct mmc_softc *sc, uint16_t resp)
 {
 	struct mmc_command cmd;
@@ -1050,6 +1094,8 @@ mmc_discover_cards(struct mmc_softc *sc)
 			if (ivar->csd.csd_structure > 0)
 				ivar->high_cap = 1;
 			ivar->tran_speed = ivar->csd.tran_speed;
+			ivar->erase_sector = ivar->csd.erase_sector * 
+			    ivar->csd.write_bl_len / MMC_SECTOR_SIZE;
 			/* Get card SCR. Card must be selected to fetch it. */
 			mmc_select_card(sc, ivar->rca);
 			mmc_app_send_scr(sc, ivar->rca, ivar->raw_scr);
@@ -1063,6 +1109,13 @@ mmc_discover_cards(struct mmc_softc *sc)
 					ivar->hs_tran_speed = 50000000;
 				}
 			}
+			mmc_app_sd_status(sc, ivar->rca, ivar->raw_sd_status);
+			mmc_app_decode_sd_status(ivar->raw_sd_status,
+			    &ivar->sd_status);
+			if (ivar->sd_status.au_size != 0) {
+				ivar->erase_sector =
+				    16 << ivar->sd_status.au_size;
+			}
 			mmc_select_card(sc, 0);
 			/* Find max supported bus width. */
 			if ((mmcbr_get_caps(sc->dev) & MMC_CAP_4_BIT_DATA) &&
@@ -1081,6 +1134,8 @@ mmc_discover_cards(struct mmc_softc *sc)
 		mmc_decode_csd_mmc(ivar->raw_csd, &ivar->csd);
 		ivar->sec_count = ivar->csd.capacity / MMC_SECTOR_SIZE;
 		ivar->tran_speed = ivar->csd.tran_speed;
+		ivar->erase_sector = ivar->csd.erase_sector * 
+		    ivar->csd.write_bl_len / MMC_SECTOR_SIZE;
 		/* Only MMC >= 4.x cards support EXT_CSD. */
 		if (ivar->csd.spec_vers >= 4) {
 			/* Card must be selected to fetch EXT_CSD. */
@@ -1108,6 +1163,13 @@ mmc_discover_cards(struct mmc_softc *sc)
 			/* Find max supported bus width. */
 			ivar->bus_width = mmc_test_bus_width(sc);
 			mmc_select_card(sc, 0);
+			/* Handle HC erase sector size. */
+			if (ivar->raw_ext_csd[EXT_CSD_ERASE_GRP_SIZE] != 0) {
+				ivar->erase_sector = 1024 *
+				    ivar->raw_ext_csd[EXT_CSD_ERASE_GRP_SIZE];
+				mmc_switch(sc, EXT_CSD_CMD_SET_NORMAL,
+				    EXT_CSD_ERASE_GRP_DEF, 1);
+			}
 		} else {
 			ivar->bus_width = bus_width_1;
 			ivar->timing = bus_timing_normal;
@@ -1278,6 +1340,9 @@ mmc_read_ivar(device_t bus, device_t chi
 	case MMC_IVAR_BUS_WIDTH:
 		*(int *)result = ivar->bus_width;
 		break;
+	case MMC_IVAR_ERASE_SECTOR:
+		*(int *)result = ivar->erase_sector;
+		break;
 	}
 	return (0);
 }

Modified: head/sys/dev/mmc/mmcreg.h
==============================================================================
--- head/sys/dev/mmc/mmcreg.h	Sat Oct 18 16:02:48 2008	(r184032)
+++ head/sys/dev/mmc/mmcreg.h	Sat Oct 18 16:17:04 2008	(r184033)
@@ -288,11 +288,14 @@ struct mmc_request {
  * EXT_CSD fields
  */
 
+#define EXT_CSD_ERASE_GRP_DEF	175	/* R/W */
 #define EXT_CSD_BUS_WIDTH	183	/* R/W */
 #define EXT_CSD_HS_TIMING	185	/* R/W */
 #define EXT_CSD_CARD_TYPE	196	/* RO */
 #define EXT_CSD_REV		192	/* RO */
 #define EXT_CSD_SEC_CNT		212	/* RO, 4 bytes */
+#define EXT_CSD_ERASE_TO_MULT	223	/* RO */
+#define EXT_CSD_ERASE_GRP_SIZE	224	/* RO */
 
 /*
  * EXT_CSD field definitions
@@ -379,7 +382,7 @@ struct mmc_csd 
 	uint32_t vdd_w_curr_min;
 	uint32_t vdd_w_curr_max;
 	uint32_t wp_grp_size;
-	uint32_t sector_size;	/* Erase sector size! */
+	uint32_t erase_sector;
 	uint64_t capacity;
 	unsigned int read_bl_partial:1,
 	    read_blk_misalign:1,
@@ -398,6 +401,20 @@ struct mmc_scr
 #define SD_SCR_BUS_WIDTH_4	(1<<2)
 };
 
+struct mmc_sd_status
+{
+	uint8_t			bus_width;
+	uint8_t			secured_mode;
+	uint16_t		card_type;
+	uint16_t		prot_area;
+	uint8_t			speed_class;
+	uint8_t			perf_move;
+	uint8_t			au_size;
+	uint16_t		erase_size;
+	uint8_t			erase_timeout;
+	uint8_t			erase_offset;
+};
+
 /*
  * Older versions of the MMC standard had a variable sector size.  However,
  * I've been able to find no old MMC or SD cards that have a non 512

Modified: head/sys/dev/mmc/mmcsd.c
==============================================================================
--- head/sys/dev/mmc/mmcsd.c	Sat Oct 18 16:02:48 2008	(r184032)
+++ head/sys/dev/mmc/mmcsd.c	Sat Oct 18 16:17:04 2008	(r184033)
@@ -133,10 +133,11 @@ mmcsd_attach(device_t dev)
 	// d->d_dump = mmcsd_dump;	Need polling mmc layer
 	d->d_name = "mmcsd";
 	d->d_drv1 = sc;
-	d->d_maxsize = MAXPHYS;		/* Maybe ask bridge? */
+	d->d_maxsize = 4*1024*1024;	/* Maximum defined SD card AU size. */
 	d->d_sectorsize = mmc_get_sector_size(dev);
 	d->d_mediasize = mmc_get_media_size(dev) * d->d_sectorsize;
 	d->d_unit = device_get_unit(dev);
+	d->d_flags = DISKFLAG_CANDELETE;
 	/*
 	 * Display in most natural units.  There's no cards < 1MB.
 	 * The SD standard goes to 2GiB, but the data format supports
@@ -216,6 +217,151 @@ mmcsd_strategy(struct bio *bp)
 	MMCSD_UNLOCK(sc);
 }
 
+static daddr_t
+mmcsd_rw(struct mmcsd_softc *sc, struct bio *bp)
+{
+	daddr_t block, end;
+	struct mmc_command cmd;
+	struct mmc_command stop;
+	struct mmc_request req;
+	struct mmc_data data;
+	device_t dev = sc->dev;
+	int sz = sc->disk->d_sectorsize;
+
+	block = bp->bio_pblkno;
+	end = bp->bio_pblkno + (bp->bio_bcount / sz);
+	while (block < end) {
+		char *vaddr = bp->bio_data +
+		    (block - bp->bio_pblkno) * sz;
+		int numblocks;
+#ifdef MULTI_BLOCK
+		numblocks = end - block;
+#else
+		numblocks = 1;
+#endif
+		memset(&req, 0, sizeof(req));
+    		memset(&cmd, 0, sizeof(cmd));
+		memset(&stop, 0, sizeof(stop));
+		req.cmd = &cmd;
+		cmd.data = &data;
+		if (bp->bio_cmd == BIO_READ) {
+			if (numblocks > 1)
+				cmd.opcode = MMC_READ_MULTIPLE_BLOCK;
+			else
+				cmd.opcode = MMC_READ_SINGLE_BLOCK;
+		} else {
+			if (numblocks > 1)
+				cmd.opcode = MMC_WRITE_MULTIPLE_BLOCK;
+			else
+				cmd.opcode = MMC_WRITE_BLOCK;
+		}
+		cmd.arg = block;
+		if (!mmc_get_high_cap(dev))
+			cmd.arg <<= 9;
+		cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
+		data.data = vaddr;
+		data.mrq = &req;
+		if (bp->bio_cmd == BIO_READ)
+			data.flags = MMC_DATA_READ;
+		else
+			data.flags = MMC_DATA_WRITE;
+		data.len = numblocks * sz;
+		if (numblocks > 1) {
+			data.flags |= MMC_DATA_MULTI;
+			stop.opcode = MMC_STOP_TRANSMISSION;
+			stop.arg = 0;
+			stop.flags = MMC_RSP_R1B | MMC_CMD_AC;
+			req.stop = &stop;
+		}
+//		printf("Len %d  %lld-%lld flags %#x sz %d\n",
+//		    (int)data.len, (long long)block, (long long)end, data.flags, sz);
+		MMCBUS_WAIT_FOR_REQUEST(device_get_parent(dev), dev,
+		    &req);
+		if (req.cmd->error != MMC_ERR_NONE)
+			break;
+		block += numblocks;
+	}
+	return (block);
+}
+
+static daddr_t
+mmcsd_delete(struct mmcsd_softc *sc, struct bio *bp)
+{
+	daddr_t block, end, start, stop;
+	struct mmc_command cmd;
+	struct mmc_request req;
+	device_t dev = sc->dev;
+	int sz = sc->disk->d_sectorsize;
+	int erase_sector;
+
+	block = bp->bio_pblkno;
+	end = bp->bio_pblkno + (bp->bio_bcount / sz);
+
+	/* Safe round to the erase sector boundaries. */
+	erase_sector = mmc_get_erase_sector(dev);
+	start = block + erase_sector - 1;	 /* Round up. */
+	start -= start % erase_sector;
+	stop = end;				/* Round down. */
+	stop -= end % erase_sector;	 
+
+	/* We can't erase areas smaller then sector. */
+	if (start >= stop)
+		return (end);
+
+	/* Set erase start position. */
+	memset(&req, 0, sizeof(req));
+	memset(&cmd, 0, sizeof(cmd));
+	req.cmd = &cmd;
+	if (mmc_get_card_type(dev) == mode_sd)
+		cmd.opcode = SD_ERASE_WR_BLK_START;
+	else
+		cmd.opcode = MMC_ERASE_GROUP_START;
+	cmd.arg = start;
+	if (!mmc_get_high_cap(dev))
+		cmd.arg <<= 9;
+	cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
+	MMCBUS_WAIT_FOR_REQUEST(device_get_parent(dev), dev,
+	    &req);
+	if (req.cmd->error != MMC_ERR_NONE) {
+	    printf("erase err1: %d\n", req.cmd->error);
+	    return (block);
+	}
+	/* Set erase stop position. */
+	memset(&req, 0, sizeof(req));
+	memset(&cmd, 0, sizeof(cmd));
+	req.cmd = &cmd;
+	if (mmc_get_card_type(dev) == mode_sd)
+		cmd.opcode = SD_ERASE_WR_BLK_END;
+	else
+		cmd.opcode = MMC_ERASE_GROUP_END;
+	cmd.arg = stop;
+	if (!mmc_get_high_cap(dev))
+		cmd.arg <<= 9;
+	cmd.arg--;
+	cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
+	MMCBUS_WAIT_FOR_REQUEST(device_get_parent(dev), dev,
+	    &req);
+	if (req.cmd->error != MMC_ERR_NONE) {
+	    printf("erase err2: %d\n", req.cmd->error);
+	    return (block);
+	}
+	/* Erase range. */
+	memset(&req, 0, sizeof(req));
+	memset(&cmd, 0, sizeof(cmd));
+	req.cmd = &cmd;
+	cmd.opcode = MMC_ERASE;
+	cmd.arg = 0;
+	cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
+	MMCBUS_WAIT_FOR_REQUEST(device_get_parent(dev), dev,
+	    &req);
+	if (req.cmd->error != MMC_ERR_NONE) {
+	    printf("erase err3 %d\n", req.cmd->error);
+	    return (block);
+	}
+
+	return (end);
+}
+
 static void
 mmcsd_task(void *arg)
 {
@@ -223,10 +369,6 @@ mmcsd_task(void *arg)
 	struct bio *bp;
 	int sz;
 	daddr_t block, end;
-	struct mmc_command cmd;
-	struct mmc_command stop;
-	struct mmc_request req;
-	struct mmc_data data;
 	device_t dev;
 
 	dev = sc->dev;
@@ -242,7 +384,6 @@ mmcsd_task(void *arg)
 		MMCSD_UNLOCK(sc);
 		if (!sc->running)
 			break;
-//		printf("mmc_task: request %p for block %ju\n", bp, bp->bio_pblkno);
 		if (bp->bio_cmd != BIO_READ && mmc_get_read_only(dev)) {
 			bp->bio_error = EROFS;
 			bp->bio_resid = bp->bio_bcount;
@@ -252,56 +393,15 @@ mmcsd_task(void *arg)
 		}
 		MMCBUS_ACQUIRE_BUS(device_get_parent(dev), dev);
 		sz = sc->disk->d_sectorsize;
+		block = bp->bio_pblkno;
 		end = bp->bio_pblkno + (bp->bio_bcount / sz);
-		for (block = bp->bio_pblkno; block < end;) {
-			char *vaddr = bp->bio_data + (block - bp->bio_pblkno) * sz;
-			int numblocks;
-#ifdef MULTI_BLOCK
-			numblocks = end - block;
-#else
-			numblocks = 1;
-#endif
-			memset(&req, 0, sizeof(req));
-			memset(&cmd, 0, sizeof(cmd));
-			memset(&stop, 0, sizeof(stop));
-			req.cmd = &cmd;
-			cmd.data = &data;
-			if (bp->bio_cmd == BIO_READ) {
-				if (numblocks > 1)
-					cmd.opcode = MMC_READ_MULTIPLE_BLOCK;
-				else
-					cmd.opcode = MMC_READ_SINGLE_BLOCK;
-			} else {
-				if (numblocks > 1)
-					cmd.opcode = MMC_WRITE_MULTIPLE_BLOCK;
-				else
-					cmd.opcode = MMC_WRITE_BLOCK;
-			}
-			cmd.arg = block;
-			if (!mmc_get_high_cap(dev))
-				cmd.arg <<= 9;
-			cmd.flags = MMC_RSP_R1 | MMC_CMD_ADTC;
-			data.data = vaddr;
-			data.mrq = &req;
-			if (bp->bio_cmd == BIO_READ)
-				data.flags = MMC_DATA_READ;
-			else
-				data.flags = MMC_DATA_WRITE;
-			data.len = numblocks * sz;
-			if (numblocks > 1) {
-				data.flags |= MMC_DATA_MULTI;
-				stop.opcode = MMC_STOP_TRANSMISSION;
-				stop.arg = 0;
-				stop.flags = MMC_RSP_R1B | MMC_CMD_AC;
-				req.stop = &stop;
-			}
-//			printf("Len %d  %lld-%lld flags %#x sz %d\n",
-//			    (int)data.len, (long long)block, (long long)end, data.flags, sz);
-			MMCBUS_WAIT_FOR_REQUEST(device_get_parent(dev), dev,
-			    &req);
-			if (req.cmd->error != MMC_ERR_NONE)
-				break;
-			block += numblocks;
+		if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE) {
+			block = mmcsd_rw(sc, bp);
+		} else if (bp->bio_cmd == BIO_DELETE) {
+			block = mmcsd_delete(sc, bp);
+		} else {
+			/* UNSUPPORTED COMMAND */
+			block = bp->bio_pblkno;
 		}
 		MMCBUS_RELEASE_BUS(device_get_parent(dev), dev);
 		if (block < end) {

Modified: head/sys/dev/mmc/mmcvar.h
==============================================================================
--- head/sys/dev/mmc/mmcvar.h	Sat Oct 18 16:02:48 2008	(r184032)
+++ head/sys/dev/mmc/mmcvar.h	Sat Oct 18 16:17:04 2008	(r184033)
@@ -67,6 +67,7 @@ enum mmc_device_ivars {
     MMC_IVAR_HIGH_CAP,
     MMC_IVAR_CARD_TYPE,
     MMC_IVAR_BUS_WIDTH,
+    MMC_IVAR_ERASE_SECTOR,
 //    MMC_IVAR_,
 };
 
@@ -85,5 +86,6 @@ MMC_ACCESSOR(read_only, READ_ONLY, int)
 MMC_ACCESSOR(high_cap, HIGH_CAP, int)
 MMC_ACCESSOR(card_type, CARD_TYPE, int)
 MMC_ACCESSOR(bus_width, BUS_WIDTH, int)
+MMC_ACCESSOR(erase_sector, ERASE_SECTOR, int)
 
 #endif /* DEV_MMC_MMCVAR_H */
From mav at FreeBSD.org  Sat Oct 18 22:22:25 2008
From: mav at FreeBSD.org (Alexander Motin)
Date: Sat Oct 18 22:22:31 2008
Subject: svn commit: r184034 - head/sys/dev/mmc
Message-ID: <200810182222.m9IMMPk4027184@svn.freebsd.org>

Author: mav
Date: Sat Oct 18 22:22:25 2008
New Revision: 184034
URL: http://svn.freebsd.org/changeset/base/184034

Log:
  Coalesce sequentional BIO_DELETE requests to slightly relax size and alignment
  constraints required by the card.

Modified:
  head/sys/dev/mmc/mmcsd.c

Modified: head/sys/dev/mmc/mmcsd.c
==============================================================================
--- head/sys/dev/mmc/mmcsd.c	Sat Oct 18 16:17:04 2008	(r184033)
+++ head/sys/dev/mmc/mmcsd.c	Sat Oct 18 22:22:25 2008	(r184034)
@@ -77,6 +77,7 @@ struct mmcsd_softc {
 	struct disk *disk;
 	struct proc *p;
 	struct bio_queue_head bio_queue;
+	daddr_t eblock, eend;	/* Range remaining after the last erase. */
 	int running;
 };
 
@@ -162,6 +163,7 @@ mmcsd_attach(device_t dev)
 	bioq_init(&sc->bio_queue);
 
 	sc->running = 1;
+	sc->eblock = sc->eend = 0;
 	kproc_create(&mmcsd_task, sc, &sc->p, 0, 0, "task: mmc/sd card");
 
 	return (0);
@@ -296,17 +298,23 @@ mmcsd_delete(struct mmcsd_softc *sc, str
 
 	block = bp->bio_pblkno;
 	end = bp->bio_pblkno + (bp->bio_bcount / sz);
-
+	/* Coalesce with part remaining from previous request. */
+	if (block > sc->eblock && block <= sc->eend)
+		block = sc->eblock;
+	if (end >= sc->eblock && end < sc->eend)
+		end = sc->eend;
 	/* Safe round to the erase sector boundaries. */
 	erase_sector = mmc_get_erase_sector(dev);
 	start = block + erase_sector - 1;	 /* Round up. */
 	start -= start % erase_sector;
 	stop = end;				/* Round down. */
 	stop -= end % erase_sector;	 
-
-	/* We can't erase areas smaller then sector. */
-	if (start >= stop)
+	/* We can't erase area smaller then sector, store it for later. */
+	if (start >= stop) {
+		sc->eblock = block;
+		sc->eend = end;
 		return (end);
+	}
 
 	/* Set erase start position. */
 	memset(&req, 0, sizeof(req));
@@ -358,7 +366,14 @@ mmcsd_delete(struct mmcsd_softc *sc, str
 	    printf("erase err3 %d\n", req.cmd->error);
 	    return (block);
 	}
-
+	/* Store one of remaining parts for the next call. */
+	if (bp->bio_pblkno >= sc->eblock || block == start) {
+		sc->eblock = stop;	/* Predict next forward. */
+		sc->eend = end;
+	} else {
+		sc->eblock = block;	/* Predict next backward. */
+		sc->eend = start;
+	}
 	return (end);
 }
 
@@ -396,12 +411,12 @@ mmcsd_task(void *arg)
 		block = bp->bio_pblkno;
 		end = bp->bio_pblkno + (bp->bio_bcount / sz);
 		if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE) {
+			/* Access to the remaining erase block obsoletes it. */
+			if (block < sc->eend && end > sc->eblock)
+				sc->eblock = sc->eend = 0;
 			block = mmcsd_rw(sc, bp);
 		} else if (bp->bio_cmd == BIO_DELETE) {
 			block = mmcsd_delete(sc, bp);
-		} else {
-			/* UNSUPPORTED COMMAND */
-			block = bp->bio_pblkno;
 		}
 		MMCBUS_RELEASE_BUS(device_get_parent(dev), dev);
 		if (block < end) {
From kientzle at FreeBSD.org  Sun Oct 19 00:13:57 2008
From: kientzle at FreeBSD.org (Tim Kientzle)
Date: Sun Oct 19 00:14:04 2008
Subject: svn commit: r184037 - head/lib/libarchive/test
Message-ID: <200810190013.m9J0DvRj029125@svn.freebsd.org>

Author: kientzle
Date: Sun Oct 19 00:13:57 2008
New Revision: 184037
URL: http://svn.freebsd.org/changeset/base/184037

Log:
  Style: Mark private data 'static', correct an old comment.
  
  MFC after:	3 days

Modified:
  head/lib/libarchive/test/test_acl_basic.c

Modified: head/lib/libarchive/test/test_acl_basic.c
==============================================================================
--- head/lib/libarchive/test/test_acl_basic.c	Sat Oct 18 22:59:39 2008	(r184036)
+++ head/lib/libarchive/test/test_acl_basic.c	Sun Oct 19 00:13:57 2008	(r184037)
@@ -27,8 +27,7 @@ __FBSDID("$FreeBSD$");
 
 /*
  * Exercise the system-independent portion of the ACL support.
- * Check that archive_entry objects can save and restore ACL data
- * and that pax archive can save and restore ACL data.
+ * Check that archive_entry objects can save and restore ACL data.
  *
  * This should work on all systems, regardless of whether local
  * filesystems support ACLs or not.
@@ -42,7 +41,7 @@ struct acl_t {
 	const char *name; /* Name of user/group, depending on tag. */
 };
 
-struct acl_t acls0[] = {
+static struct acl_t acls0[] = {
 	{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE,
 	  ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" },
 	{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
@@ -51,7 +50,7 @@ struct acl_t acls0[] = {
 	  ARCHIVE_ENTRY_ACL_OTHER, 0, "" },
 };
 
-struct acl_t acls1[] = {
+static struct acl_t acls1[] = {
 	{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE,
 	  ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
 	{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
@@ -62,7 +61,7 @@ struct acl_t acls1[] = {
 	  ARCHIVE_ENTRY_ACL_OTHER, -1, "" },
 };
 
-struct acl_t acls2[] = {
+static struct acl_t acls2[] = {
 	{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ,
 	  ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
 	{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
From kientzle at FreeBSD.org  Sun Oct 19 00:18:45 2008
From: kientzle at FreeBSD.org (Tim Kientzle)
Date: Sun Oct 19 00:18:57 2008
Subject: svn commit: r184038 - in head/lib/libarchive: . test
Message-ID: <200810190018.m9J0Ijst029262@svn.freebsd.org>

Author: kientzle
Date: Sun Oct 19 00:18:44 2008
New Revision: 184038
URL: http://svn.freebsd.org/changeset/base/184038

Log:
  Add test to verify ACL restores on FreeBSD, verify kern/128203 (mtime
  restore fails if ACL provided), apply patch from kern/128203, and verify fix.
  
  PR:		kern/128203
  Submitted by:	Udo Schweigert
  MFC after:	3 days

Added:
  head/lib/libarchive/test/test_acl_freebsd.c   (contents, props changed)
Modified:
  head/lib/libarchive/archive_write_disk.c
  head/lib/libarchive/test/Makefile

Modified: head/lib/libarchive/archive_write_disk.c
==============================================================================
--- head/lib/libarchive/archive_write_disk.c	Sun Oct 19 00:13:57 2008	(r184037)
+++ head/lib/libarchive/archive_write_disk.c	Sun Oct 19 00:18:44 2008	(r184038)
@@ -710,10 +710,6 @@ _archive_write_finish_entry(struct archi
 		int r2 = set_mode(a, a->mode);
 		if (r2 < ret) ret = r2;
 	}
-	if (a->todo & TODO_TIMES) {
-		int r2 = set_times(a);
-		if (r2 < ret) ret = r2;
-	}
 	if (a->todo & TODO_ACLS) {
 		int r2 = set_acls(a);
 		if (r2 < ret) ret = r2;
@@ -726,6 +722,10 @@ _archive_write_finish_entry(struct archi
 		int r2 = set_fflags(a);
 		if (r2 < ret) ret = r2;
 	}
+	if (a->todo & TODO_TIMES) {
+		int r2 = set_times(a);
+		if (r2 < ret) ret = r2;
+	}
 
 	/* If there's an fd, we can close it now. */
 	if (a->fd >= 0) {

Modified: head/lib/libarchive/test/Makefile
==============================================================================
--- head/lib/libarchive/test/Makefile	Sun Oct 19 00:13:57 2008	(r184037)
+++ head/lib/libarchive/test/Makefile	Sun Oct 19 00:18:44 2008	(r184038)
@@ -9,6 +9,7 @@ LA_SRCS!=make -f ${LA_SRCDIR}/Makefile -
 
 TESTS= \
 	test_acl_basic.c			\
+	test_acl_freebsd.c			\
 	test_acl_pax.c				\
 	test_archive_api_feature.c		\
 	test_bad_fd.c				\

Added: head/lib/libarchive/test/test_acl_freebsd.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lib/libarchive/test/test_acl_freebsd.c	Sun Oct 19 00:18:44 2008	(r184038)
@@ -0,0 +1,243 @@
+/*-
+ * Copyright (c) 2003-2008 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+#if defined(__FreeBSD__) && __FreeBSD__ > 4
+#include 
+
+struct myacl_t {
+	int type;  /* Type of ACL: "access" or "default" */
+	int permset; /* Permissions for this class of users. */
+	int tag; /* Owner, User, Owning group, group, other, etc. */
+	int qual; /* GID or UID of user/group, depending on tag. */
+	const char *name; /* Name of user/group, depending on tag. */
+};
+
+static struct myacl_t acls2[] = {
+	{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ,
+	  ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
+	{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
+	  ARCHIVE_ENTRY_ACL_USER, 77, "user77" },
+	{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0,
+	  ARCHIVE_ENTRY_ACL_USER, 78, "user78" },
+	{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
+	  ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" },
+	{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0007,
+	  ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" },
+	{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+	  ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_EXECUTE,
+	  ARCHIVE_ENTRY_ACL_OTHER, -1, "" },
+	{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+	  ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ | ARCHIVE_ENTRY_ACL_EXECUTE,
+	  ARCHIVE_ENTRY_ACL_MASK, -1, "" },
+	{ 0, 0, 0, 0, NULL }
+};
+
+static void
+set_acls(struct archive_entry *ae, struct myacl_t *acls)
+{
+	int i;
+
+	archive_entry_acl_clear(ae);
+	for (i = 0; acls[i].name != NULL; i++) {
+		archive_entry_acl_add_entry(ae,
+		    acls[i].type, acls[i].permset, acls[i].tag, acls[i].qual,
+		    acls[i].name);
+	}
+}
+
+static int
+acl_match(acl_entry_t aclent, struct myacl_t *myacl)
+{
+	acl_tag_t tag_type;
+	acl_permset_t opaque_ps;
+	int permset = 0;
+
+	acl_get_tag_type(aclent, &tag_type);
+
+	/* translate the silly opaque permset to a bitmap */
+	acl_get_permset(aclent, &opaque_ps);
+	if (acl_get_perm_np(opaque_ps, ACL_EXECUTE))
+		permset |= ARCHIVE_ENTRY_ACL_EXECUTE;
+	if (acl_get_perm_np(opaque_ps, ACL_WRITE))
+		permset |= ARCHIVE_ENTRY_ACL_WRITE;
+	if (acl_get_perm_np(opaque_ps, ACL_READ))
+		permset |= ARCHIVE_ENTRY_ACL_READ;
+
+	if (permset != myacl->permset)
+		return (0);
+
+	switch (tag_type) {
+	case ACL_USER_OBJ:
+		if (myacl->tag != ARCHIVE_ENTRY_ACL_USER_OBJ) return (0);
+		break;
+	case ACL_USER:
+		if (myacl->tag != ARCHIVE_ENTRY_ACL_USER)
+			return (0);
+		if ((uid_t)myacl->qual != *(uid_t *)acl_get_qualifier(aclent))
+			return (0);
+		break;
+	case ACL_GROUP_OBJ:
+		if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP_OBJ) return (0);
+		break;
+	case ACL_GROUP:
+		if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP)
+			return (0);
+		if ((gid_t)myacl->qual != *(gid_t *)acl_get_qualifier(aclent))
+			return (0);
+		break;
+	case ACL_MASK:
+		if (myacl->tag != ARCHIVE_ENTRY_ACL_MASK) return (0);
+		break;
+	case ACL_OTHER:
+		if (myacl->tag != ARCHIVE_ENTRY_ACL_OTHER) return (0);
+		break;
+	}
+	return (1);
+}
+
+static void
+compare_acls(acl_t acl, struct myacl_t *myacls)
+{
+	int *marker;
+	int entry_id = ACL_FIRST_ENTRY;
+	int matched;
+	int i, n;
+	acl_entry_t acl_entry;
+
+	/* Count ACL entries in myacls array and allocate an indirect array. */
+	for (n = 0; myacls[n].name != NULL; ++n)
+		continue;
+	marker = malloc(sizeof(marker[0]) * n);
+	for (i = 0; i < n; i++)
+		marker[i] = i;
+
+	/*
+	 * Iterate over acls in system acl object, try to match each
+	 * one with an item in the myacls array.
+	 */
+	while (1 == acl_get_entry(acl, entry_id, &acl_entry)) {
+		/* After the first time... */
+		entry_id = ACL_NEXT_ENTRY;
+
+		/* Search for a matching entry (tag and qualifier) */
+		for (i = 0, matched = 0; i < n && !matched; i++) {
+			if (acl_match(acl_entry, &myacls[marker[i]])) {
+				/* We found a match; remove it. */
+				marker[i] = marker[n - 1];
+				n--;
+				matched = 1;
+			}
+		}
+
+		/* TODO: Print out more details in this case. */
+		failure("ACL entry on file that shouldn't be there");
+		assert(matched == 1);
+	}
+
+	/* Dump entries in the myacls array that weren't in the system acl. */
+	for (i = 0; i < n; ++i) {
+		failure(" ACL entry missing from file: "
+		    "type=%d,permset=%d,tag=%d,qual=%d,name=``%s''\n",
+		    myacls[marker[i]].type, myacls[marker[i]].permset,
+		    myacls[marker[i]].tag, myacls[marker[i]].qual,
+		    myacls[marker[i]].name);
+		assert(0); /* Record this as a failure. */
+	}
+	free(marker);
+}
+
+#endif
+
+
+/*
+ * Verify ACL restore-to-disk.  This test is FreeBSD-specific.
+ */
+
+DEFINE_TEST(test_acl_freebsd)
+{
+#if !defined(__FreeBSD__)
+	skipping("FreeBSD-specific ACL restore test");
+#elif __FreeBSD__ < 5
+	skipping("ACL restore supported only on FreeBSD 5.0 and later");
+#else
+	struct stat st;
+	struct archive *a;
+	struct archive_entry *ae;
+	int n, fd;
+	acl_t acl;
+
+	/*
+	 * First, do a quick manual set/read of ACL data to
+	 * verify that the local filesystem does support ACLs.
+	 * If it doesn't, we'll simply skip the remaining tests.
+	 */
+	acl = acl_from_text("u::rwx,u:1:rw,g::rwx,g:15:rx,o::rwx,m::rwx");
+	assert((void *)acl != NULL);
+	/* Create a test file and try to set an ACL on it. */
+	fd = open("pretest", O_WRONLY | O_CREAT | O_EXCL, 0777);
+	failure("Could not create test file?!");
+	n = -1;
+	if (assert(fd >= 0)) {
+		n = acl_set_fd(fd, acl);
+		failure("acl_set_fd(): errno = %d (%s)",
+		    errno, strerror(errno));
+		assertEqualInt(0, n);
+		close(fd);
+	}
+
+	if (fd < 0 || n != 0) {
+		skipping("ACL tests require that ACL support be enabled on the filesystem");
+		return;
+	}
+
+	/* Create a write-to-disk object. */
+	assert(NULL != (a = archive_write_disk_new()));
+	archive_write_disk_set_options(a,
+	    ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_ACL);
+
+	/* Populate an archive entry with some metadata, including ACL info */
+	ae = archive_entry_new();
+	assert(ae != NULL);
+	archive_entry_set_pathname(ae, "test0");
+	archive_entry_set_mtime(ae, 123456, 7890);
+	archive_entry_set_size(ae, 0);
+	set_acls(ae, acls2);
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+	archive_entry_free(ae);
+
+	/* Close the archive. */
+	assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+	assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+	/* Verify the data on disk. */
+	assertEqualInt(0, stat("test0", &st));
+	assertEqualInt(st.st_mtime, 123456);
+	acl = acl_get_file("test0", ACL_TYPE_ACCESS);
+	assert(acl != (acl_t)NULL);
+	compare_acls(acl, acls2);
+#endif
+}
From kmacy at FreeBSD.org  Sun Oct 19 01:23:30 2008
From: kmacy at FreeBSD.org (Kip Macy)
Date: Sun Oct 19 01:23:42 2008
Subject: svn commit: r184039 - in head/sys/i386: include xen
Message-ID: <200810190123.m9J1NUZm030428@svn.freebsd.org>

Author: kmacy
Date: Sun Oct 19 01:23:30 2008
New Revision: 184039
URL: http://svn.freebsd.org/changeset/base/184039

Log:
  GC unused values

Modified:
  head/sys/i386/include/trap.h
  head/sys/i386/xen/locore.s

Modified: head/sys/i386/include/trap.h
==============================================================================
--- head/sys/i386/include/trap.h	Sun Oct 19 00:18:44 2008	(r184038)
+++ head/sys/i386/include/trap.h	Sun Oct 19 01:23:30 2008	(r184039)
@@ -49,9 +49,6 @@
 #define	T_PAGEFLT	12	/* page fault */
 #define	T_ALIGNFLT	14	/* alignment fault */
 
-#ifdef XEN
-#define	T_HYPCALLBACK	17	/* hypervisor upcall */
-#endif
 #define	T_DIVIDE	18	/* integer divide fault */
 #define	T_NMI		19	/* non-maskable trap */
 #define	T_OFLOW		20	/* overflow trap */

Modified: head/sys/i386/xen/locore.s
==============================================================================
--- head/sys/i386/xen/locore.s	Sun Oct 19 00:18:44 2008	(r184038)
+++ head/sys/i386/xen/locore.s	Sun Oct 19 01:23:30 2008	(r184039)
@@ -136,16 +136,6 @@ KERNend:	.long	0		/* phys addr end of ke
 		.globl physfree
 physfree:	.long	0		/* phys addr of next free page */
 
-#ifdef SMP
-		.globl	cpu0prvpage
-cpu0pp:		.long	0		/* phys addr cpu0 private pg */
-cpu0prvpage:	.long	0		/* relocated version */
-
-		.globl	SMPpt
-SMPptpa:	.long	0		/* phys addr SMP page table */
-SMPpt:		.long	0		/* relocated version */
-#endif /* SMP */
-
 	.globl	IdlePTD
 IdlePTD:	.long	0		/* phys addr of kernel PTD */
 
From kmacy at FreeBSD.org  Sun Oct 19 01:27:41 2008
From: kmacy at FreeBSD.org (Kip Macy)
Date: Sun Oct 19 01:27:48 2008
Subject: svn commit: r184040 - in head/sys/i386: include xen
Message-ID: <200810190127.m9J1ReEj030526@svn.freebsd.org>

Author: kmacy
Date: Sun Oct 19 01:27:40 2008
New Revision: 184040
URL: http://svn.freebsd.org/changeset/base/184040

Log:
  - move gdt, ldt allocation to before KPT allocation
  - fix bugs where we would:
      - try to map the hypervisors address space
      - accidentally kick out an existing kernel mapping for some domain creation memory allocation sizes
      - accidentally skip a 2MB kernel mapping for some domain creation memory allocation sizes
  - don't rely on trapping in to xen to read rcr2, reference through vcpu
  - whitespace cleanups

Modified:
  head/sys/i386/include/cpufunc.h
  head/sys/i386/xen/xen_machdep.c

Modified: head/sys/i386/include/cpufunc.h
==============================================================================
--- head/sys/i386/include/cpufunc.h	Sun Oct 19 01:23:30 2008	(r184039)
+++ head/sys/i386/include/cpufunc.h	Sun Oct 19 01:27:40 2008	(r184040)
@@ -45,6 +45,7 @@
 #ifdef XEN
 extern void xen_cli(void);
 extern void xen_sti(void);
+extern u_int xen_rcr2(void);
 extern void xen_load_cr3(u_int data);
 extern void xen_tlb_flush(void);
 extern void xen_invlpg(u_int addr);
@@ -94,7 +95,7 @@ disable_intr(void)
 #ifdef XEN
 	xen_cli();
 #else	
-    __asm __volatile("cli" : : : "memory");
+	__asm __volatile("cli" : : : "memory");
 #endif
 }
 
@@ -119,7 +120,7 @@ enable_intr(void)
 {
 #ifdef XEN
 	xen_sti();
-#else	
+#else
 	__asm __volatile("sti");
 #endif
 }
@@ -423,6 +424,9 @@ rcr2(void)
 {
 	u_int	data;
 
+#ifdef XEN
+	return (xen_rcr2());
+#endif
 	__asm __volatile("movl %%cr2,%0" : "=r" (data));
 	return (data);
 }

Modified: head/sys/i386/xen/xen_machdep.c
==============================================================================
--- head/sys/i386/xen/xen_machdep.c	Sun Oct 19 01:23:30 2008	(r184039)
+++ head/sys/i386/xen/xen_machdep.c	Sun Oct 19 01:27:40 2008	(r184040)
@@ -202,21 +202,20 @@ static struct mmu_log xpq_queue_log[MAX_
 static int xpq_idx[MAX_VIRT_CPUS];  
 static mmu_update_t xpq_queue[MAX_VIRT_CPUS][XPQUEUE_SIZE];
 
-#define XPQ_QUEUE xpq_queue[vcpu]
-#define XPQ_IDX xpq_idx[vcpu]
-#define SET_VCPU() int vcpu = smp_processor_id()
-
-
-#define XPQ_QUEUE_LOG xpq_queue_log[vcpu]
+#define	XPQ_QUEUE_LOG xpq_queue_log[vcpu]
+#define	XPQ_QUEUE xpq_queue[vcpu]
+#define	XPQ_IDX xpq_idx[vcpu]
+#define	SET_VCPU() int vcpu = smp_processor_id()
 #else
 	
 static mmu_update_t xpq_queue[XPQUEUE_SIZE];
 static struct mmu_log xpq_queue_log[XPQUEUE_SIZE];
 static int xpq_idx = 0;
 
-#define XPQ_QUEUE xpq_queue
-#define XPQ_IDX xpq_idx
-#define SET_VCPU()
+#define	XPQ_QUEUE_LOG xpq_queue_log
+#define	XPQ_QUEUE xpq_queue
+#define	XPQ_IDX xpq_idx
+#define	SET_VCPU()
 #endif /* !SMP */
 
 #define XPQ_IDX_INC atomic_add_int(&XPQ_IDX, 1);
@@ -371,6 +370,13 @@ xen_sti(void)
 	__sti();
 }
 
+u_int
+xen_rcr2(void)
+{
+
+	return (HYPERVISOR_shared_info->vcpu_info[curcpu].arch.cr2);
+}
+
 void
 _xen_machphys_update(vm_paddr_t mfn, vm_paddr_t pfn, char *file, int line)
 {
@@ -810,7 +816,7 @@ void
 initvalues(start_info_t *startinfo)
 { 
 	int l3_pages, l2_pages, l1_pages, offset;
-	vm_offset_t cur_space;
+	vm_offset_t cur_space, cur_space_pt;
 	struct physdev_set_iopl set_iopl;
 	
 	vm_paddr_t KPTphys, IdlePTDma;
@@ -825,15 +831,13 @@ initvalues(start_info_t *startinfo)
 	vm_paddr_t pdir_shadow_ma;
 #endif
 	unsigned long i;
-	int ncpus;
+	int ncpus = MAXCPU;
 
-	nkpt = min(max((startinfo->nr_pages >> NPGPTD_SHIFT), nkpt),
-	    NPGPTD*NPDEPG - KPTDI);
-#ifdef SMP
-	ncpus = MAXCPU;
-#else
-	ncpus = 1;
-#endif	
+	nkpt = min(
+		min(
+			max((startinfo->nr_pages >> NPGPTD_SHIFT), nkpt),
+		    NPGPTD*NPDEPG - KPTDI),
+		    (HYPERVISOR_VIRT_START - KERNBASE) >> PDRSHIFT);
 
 	HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);	
 #ifdef notyet
@@ -859,7 +863,24 @@ initvalues(start_info_t *startinfo)
 	bootmem_start = bootmem_current = (char *)cur_space;
 	cur_space += (4 * PAGE_SIZE);
 	bootmem_end = (char *)cur_space;
+
+	/* allocate page for gdt */
+	gdt = (union descriptor *)cur_space;
+	cur_space += PAGE_SIZE*ncpus;
+
+        /* allocate page for ldt */
+	ldt = (union descriptor *)cur_space; cur_space += PAGE_SIZE;
+	cur_space += PAGE_SIZE;
 	
+	HYPERVISOR_shared_info = (shared_info_t *)cur_space;
+	cur_space += PAGE_SIZE;
+
+	xen_store = (struct ringbuf_head *)cur_space;
+	cur_space += PAGE_SIZE;
+
+	console_page = (char *)cur_space;
+	cur_space += PAGE_SIZE;
+
 #ifdef ADD_ISA_HOLE
 	shift_phys_machine(xen_phys_machine, xen_start_info->nr_pages);
 #endif
@@ -936,6 +957,16 @@ initvalues(start_info_t *startinfo)
 	 * Unpin the current PDPT
 	 */
 	xen_pt_unpin(IdlePDPTma);
+	
+	for (i = 0; i < 20; i++) {
+		int startidx = ((KERNBASE >> 18) & PAGE_MASK) >> 3;
+
+		if (IdlePTD[startidx + i] == 0) {
+			l1_pages = i;
+			break;
+		}	
+	}
+
 #endif  /* PAE */
 	
 	/* unmap remaining pages from initial 4MB chunk
@@ -947,7 +978,7 @@ initvalues(start_info_t *startinfo)
 	}
 	
 	PT_UPDATES_FLUSH();
-  
+
 	memcpy(((uint8_t *)IdlePTDnew) + ((unsigned int)(KERNBASE >> 18)),
 	    ((uint8_t *)IdlePTD) + ((KERNBASE >> 18) & PAGE_MASK),
 	    l1_pages*sizeof(pt_entry_t));
@@ -960,18 +991,22 @@ initvalues(start_info_t *startinfo)
 	xen_pgdpt_pin(xpmap_ptom(VTOP(IdlePDPTnew)));
 
 	/* allocate remainder of nkpt pages */
-	for (offset = (KERNBASE >> PDRSHIFT), i = l1_pages - 1; i < nkpt;
+	cur_space_pt = cur_space;
+	for (offset = (KERNBASE >> PDRSHIFT), i = l1_pages; i < nkpt;
 	     i++, cur_space += PAGE_SIZE) {
 		pdir = (offset + i) / NPDEPG;
 		curoffset = ((offset + i) % NPDEPG);
-		
+		if (((offset + i) << PDRSHIFT) == VM_MAX_KERNEL_ADDRESS)
+			break;
+
 		/*
 		 * make sure that all the initial page table pages
 		 * have been zeroed
 		 */
-		PT_SET_MA(cur_space, xpmap_ptom(VTOP(cur_space)) | PG_V | PG_RW);
-		bzero((char *)cur_space, PAGE_SIZE);
-		PT_SET_MA(cur_space, (vm_paddr_t)0);
+		PT_SET_MA(cur_space_pt,
+		    xpmap_ptom(VTOP(cur_space)) | PG_V | PG_RW);
+		bzero((char *)cur_space_pt, PAGE_SIZE);
+		PT_SET_MA(cur_space_pt, (vm_paddr_t)0);
 		xen_pt_pin(xpmap_ptom(VTOP(cur_space)));
 		xen_queue_pt_update((vm_paddr_t)(IdlePTDnewma[pdir] +
 			curoffset*sizeof(vm_paddr_t)), 
@@ -994,17 +1029,6 @@ initvalues(start_info_t *startinfo)
 	IdlePDPT = IdlePDPTnew;
 	IdlePDPTma = IdlePDPTnewma;
 	
-	/* allocate page for gdt */
-	gdt = (union descriptor *)cur_space;
-	cur_space += PAGE_SIZE*ncpus;
-
-        /* allocate page for ldt */
-	ldt = (union descriptor *)cur_space; cur_space += PAGE_SIZE;
-	cur_space += PAGE_SIZE;
-	
-	HYPERVISOR_shared_info = (shared_info_t *)cur_space;
-	cur_space += PAGE_SIZE;
-
 	/*
 	 * shared_info is an unsigned long so this will randomly break if
 	 * it is allocated above 4GB - I guess people are used to that
@@ -1015,13 +1039,8 @@ initvalues(start_info_t *startinfo)
 	
 	printk("#4\n");
 
-	xen_store = (struct ringbuf_head *)cur_space;
-	cur_space += PAGE_SIZE;
-	
 	xen_store_ma = (((vm_paddr_t)xen_start_info->store_mfn) << PAGE_SHIFT);
 	PT_SET_MA(xen_store, xen_store_ma | PG_KERNEL);
-	console_page = (char *)cur_space;
-	cur_space += PAGE_SIZE;
 	console_page_ma = (((vm_paddr_t)xen_start_info->console.domU.mfn) << PAGE_SHIFT);
 	PT_SET_MA(console_page, console_page_ma | PG_KERNEL);
 
From kmacy at FreeBSD.org  Sun Oct 19 01:33:58 2008
From: kmacy at FreeBSD.org (Kip Macy)
Date: Sun Oct 19 01:34:10 2008
Subject: svn commit: r184041 - head/sys/i386/i386
Message-ID: <200810190133.m9J1Xwq2030682@svn.freebsd.org>

Author: kmacy
Date: Sun Oct 19 01:33:58 2008
New Revision: 184041
URL: http://svn.freebsd.org/changeset/base/184041

Log:
  GC gratuitous XEN defines

Modified:
  head/sys/i386/i386/trap.c

Modified: head/sys/i386/i386/trap.c
==============================================================================
--- head/sys/i386/i386/trap.c	Sun Oct 19 01:27:40 2008	(r184040)
+++ head/sys/i386/i386/trap.c	Sun Oct 19 01:33:58 2008	(r184041)
@@ -159,11 +159,7 @@ static char *trap_msg[] = {
 	"alignment fault",			/* 14 T_ALIGNFLT */
 	"",					/* 15 unused */
 	"",					/* 16 unused */
-#ifdef XEN
-	"hypervisor callback",			/* 17 T_HYPCALLBACK*/
-#else	
 	"",					/* 17 unused */
-#endif
 	"integer divide fault",			/* 18 T_DIVIDE */
 	"non-maskable interrupt trap",		/* 19 T_NMI */
 	"overflow trap",			/* 20 T_OFLOW */
@@ -270,7 +266,6 @@ trap(struct trapframe *frame)
 			goto out;
 #endif
 
-#ifndef XEN
 	if ((frame->tf_eflags & PSL_I) == 0) {
 		/*
 		 * Buggy application or kernel code has disabled
@@ -301,7 +296,6 @@ trap(struct trapframe *frame)
 				enable_intr();
 		}
 	}
-#endif /* !XEN */  
 	eva = 0;
 	code = frame->tf_err;
 	if (type == T_PAGEFLT) {
From kmacy at FreeBSD.org  Sun Oct 19 01:35:27 2008
From: kmacy at FreeBSD.org (Kip Macy)
Date: Sun Oct 19 01:35:39 2008
Subject: svn commit: r184042 - head/sys/kern
Message-ID: <200810190135.m9J1ZRl3030744@svn.freebsd.org>

Author: kmacy
Date: Sun Oct 19 01:35:27 2008
New Revision: 184042
URL: http://svn.freebsd.org/changeset/base/184042

Log:
  - Forward port flush of page table updates on context switch or userret
  - Forward port vfork XEN hack

Modified:
  head/sys/kern/kern_fork.c
  head/sys/kern/kern_synch.c
  head/sys/kern/subr_trap.c

Modified: head/sys/kern/kern_fork.c
==============================================================================
--- head/sys/kern/kern_fork.c	Sun Oct 19 01:33:58 2008	(r184041)
+++ head/sys/kern/kern_fork.c	Sun Oct 19 01:35:27 2008	(r184042)
@@ -117,10 +117,15 @@ vfork(td, uap)
 	struct thread *td;
 	struct vfork_args *uap;
 {
-	int error;
+	int error, flags;
 	struct proc *p2;
 
-	error = fork1(td, RFFDG | RFPROC | RFPPWAIT | RFMEM, 0, &p2);
+#ifdef XEN
+	flags = RFFDG | RFPROC; /* validate that this is still an issue */
+#else
+	flags = RFFDG | RFPROC | RFPPWAIT | RFMEM;
+#endif		
+	error = fork1(td, flags, 0, &p2);
 	if (error == 0) {
 		td->td_retval[0] = p2->p_pid;
 		td->td_retval[1] = 0;

Modified: head/sys/kern/kern_synch.c
==============================================================================
--- head/sys/kern/kern_synch.c	Sun Oct 19 01:33:58 2008	(r184041)
+++ head/sys/kern/kern_synch.c	Sun Oct 19 01:35:27 2008	(r184042)
@@ -65,6 +65,12 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
+#ifdef XEN
+#include 
+#include 
+#include 
+#endif
+
 static void synch_setup(void *dummy);
 SYSINIT(synch_setup, SI_SUB_KICK_SCHEDULER, SI_ORDER_FIRST, synch_setup,
     NULL);
@@ -432,6 +438,9 @@ mi_switch(int flags, struct thread *newt
 		    td, td->td_name, td->td_priority,
 		    td->td_inhibitors, td->td_wmesg, td->td_lockname);
 #endif
+#ifdef XEN
+	PT_UPDATES_FLUSH();
+#endif
 	sched_switch(td, newtd, flags);
 	CTR3(KTR_SCHED, "mi_switch: running %p(%s) prio %d",
 	    td, td->td_name, td->td_priority);

Modified: head/sys/kern/subr_trap.c
==============================================================================
--- head/sys/kern/subr_trap.c	Sun Oct 19 01:33:58 2008	(r184041)
+++ head/sys/kern/subr_trap.c	Sun Oct 19 01:35:27 2008	(r184042)
@@ -73,6 +73,12 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#ifdef XEN
+#include 
+#include 
+#include 
+#endif
+
 #include 
 
 /*
@@ -118,6 +124,9 @@ userret(struct thread *td, struct trapfr
 	sched_userret(td);
 	KASSERT(td->td_locks == 0,
 	    ("userret: Returning with %d locks held.", td->td_locks));
+#ifdef XEN
+	PT_UPDATES_FLUSH();
+#endif
 }
 
 /*
From sam at FreeBSD.org  Sun Oct 19 06:58:32 2008
From: sam at FreeBSD.org (Sam Leffler)
Date: Sun Oct 19 06:58:43 2008
Subject: svn commit: r184048 - head/tools/tools/nanobsd
Message-ID: <200810190658.m9J6wVvB036544@svn.freebsd.org>

Author: sam
Date: Sun Oct 19 06:58:31 2008
New Revision: 184048
URL: http://svn.freebsd.org/changeset/base/184048

Log:
  add -n option to suppress clearing the build tree and add -DNO_CLEAN
  to buildworld and/or buildkernel

Modified:
  head/tools/tools/nanobsd/nanobsd.sh

Modified: head/tools/tools/nanobsd/nanobsd.sh
==============================================================================
--- head/tools/tools/nanobsd/nanobsd.sh	Sun Oct 19 06:55:08 2008	(r184047)
+++ head/tools/tools/nanobsd/nanobsd.sh	Sun Oct 19 06:58:31 2008	(r184048)
@@ -665,6 +665,7 @@ usage () {
 	echo "	-b	suppress builds (both kernel and world)"
 	echo "	-i	suppress disk image build"
 	echo "	-k	suppress buildkernel"
+	echo "	-n	add -DNO_CLEAN to buildworld, buildkernel, etc"
 	echo "	-q	make output more quite"
 	echo "	-v	make output more verbose"
 	echo "	-w	suppress buildworld"
@@ -676,12 +677,13 @@ usage () {
 #######################################################################
 # Parse arguments
 
+do_clean=true
 do_kernel=true
 do_world=true
 do_image=true
 
 set +e
-args=`getopt bc:hikqvw $*`
+args=`getopt bc:hiknqvw $*`
 if [ $? -ne 0 ] ; then
 	usage
 	exit 2
@@ -714,6 +716,10 @@ do
 		do_image=false
 		shift
 		;;
+	-n)
+		do_clean=false
+		shift
+		;;
 	-q)
 		PPLEVEL=$(($PPLEVEL - 1))
 		shift
@@ -763,6 +769,12 @@ else
 	exit 1
 fi
 
+if $do_clean ; then
+	true
+else
+	NANO_PMAKE="${NANO_PMAKE} -DNO_CLEAN"
+fi
+
 export MAKEOBJDIRPREFIX
 
 export NANO_ARCH
@@ -793,7 +805,11 @@ export NANO_BOOTLOADER
 pprint 1 "NanoBSD image ${NANO_NAME} build starting"
 
 if $do_world ; then
-	clean_build
+	if $do_clean ; then
+		clean_build
+	else
+		pprint 2 "Using existing build tree (as instructed)"
+	fi
 	make_conf_build
 	build_world
 else
From keramida at freebsd.org  Sun Oct 19 08:31:33 2008
From: keramida at freebsd.org (Giorgos Keramidas)
Date: Sun Oct 19 08:31:40 2008
Subject: svn commit: r184018 - head/share/man/man4
In-Reply-To: <200810180623.m9I6N8Wn008930@svn.freebsd.org> (Ed Schouten's
	message of "Sat, 18 Oct 2008 06:23:08 +0000 (UTC)")
References: <200810180623.m9I6N8Wn008930@svn.freebsd.org>
Message-ID: <87myh19f3v.fsf@kobe.laptop>

On Sat, 18 Oct 2008 06:23:08 +0000 (UTC), Ed Schouten  wrote:
> Author: ed
> Date: Sat Oct 18 06:23:08 2008
> New Revision: 184018
> URL: http://svn.freebsd.org/changeset/base/184018
>
> Log:
>   Increase the date in the manual page, which should have been done in
>   r183922.
>
>   In r183922 I introduced a new DDB command, documented it, but forgot
>   to bump the date in the manual page.
>
>   Pointed out by:	bz

Hi Ed,

Everyone writing manpage patches eventually learns what ``bump .Dd''
means, so if you find yourself bumping manpage dates in the future, you
can save a bit of typing by using a shorter commit log like:

        Bump .Dd for change 183922

        Pointed out by:     bz

Thanks to you and Bjoern for the extra care about the quality of our
manpages :)

From delphij at FreeBSD.org  Sun Oct 19 09:10:45 2008
From: delphij at FreeBSD.org (Xin LI)
Date: Sun Oct 19 09:10:50 2008
Subject: svn commit: r184055 - head/lib/libc/string
Message-ID: <200810190910.m9J9Ajmj038999@svn.freebsd.org>

Author: delphij
Date: Sun Oct 19 09:10:44 2008
New Revision: 184055
URL: http://svn.freebsd.org/changeset/base/184055

Log:
  Further simplify the code.
  
  Submitted by:	Christoph Mallon 

Modified:
  head/lib/libc/string/strxfrm.c

Modified: head/lib/libc/string/strxfrm.c
==============================================================================
--- head/lib/libc/string/strxfrm.c	Sun Oct 19 09:08:59 2008	(r184054)
+++ head/lib/libc/string/strxfrm.c	Sun Oct 19 09:10:44 2008	(r184055)
@@ -45,17 +45,8 @@ strxfrm(char * __restrict dest, const ch
 		return 0;
 	}
 
-	if (__collate_load_error) {
-		slen = strlen(src);
-		if (len > 0) {
-			if (slen < len)
-				strcpy(dest, src);
-			else {
-				strlcpy(dest, src, len);
-			}
-		}
-		return slen;
-	}
+	if (__collate_load_error)
+		return strlcpy(dest, src, len);
 
 	slen = 0;
 	prim = sec = 0;
From keramida at FreeBSD.org  Sun Oct 19 09:45:30 2008
From: keramida at FreeBSD.org (Giorgos Keramidas)
Date: Sun Oct 19 09:45:41 2008
Subject: svn commit: r184057 - head/sbin/ifconfig
Message-ID: <200810190945.m9J9jT9c039656@svn.freebsd.org>

Author: keramida (doc committer)
Date: Sun Oct 19 09:45:29 2008
New Revision: 184057
URL: http://svn.freebsd.org/changeset/base/184057

Log:
  Tiny wording nits.
  
  MFC after:	1 week

Modified:
  head/sbin/ifconfig/ifconfig.8

Modified: head/sbin/ifconfig/ifconfig.8
==============================================================================
--- head/sbin/ifconfig/ifconfig.8	Sun Oct 19 09:42:09 2008	(r184056)
+++ head/sbin/ifconfig/ifconfig.8	Sun Oct 19 09:45:29 2008	(r184057)
@@ -28,7 +28,7 @@
 .\"     From: @(#)ifconfig.8	8.3 (Berkeley) 1/5/94
 .\" $FreeBSD$
 .\"
-.Dd September 5, 2008
+.Dd October 19, 2008
 .Dt IFCONFIG 8
 .Os
 .Sh NAME
@@ -106,7 +106,7 @@ slash notation) to include the netmask.
 That is, one can specify an address like
 .Li 192.168.0.1/16 .
 .Pp
-For
+For the
 .Dq inet6
 family, it is also possible to specify the prefix length using the slash
 notation, like
@@ -1249,11 +1249,12 @@ If the
 .Fl v
 flag is used all the information elements and their
 contents will be shown.
-Specifying The
+Specifying the
 .Fl v
 flag also enables display of long SSIDs.
+The
 .Cm list ap
-is another way of requesting this information.
+command is another way of requesting this information.
 .It Cm list sta
 When operating as an access point display the stations that are
 currently associated.
From kib at FreeBSD.org  Sun Oct 19 10:02:27 2008
From: kib at FreeBSD.org (Konstantin Belousov)
Date: Sun Oct 19 10:02:33 2008
Subject: svn commit: r184058 - in head/sys: amd64/linux32 compat/linux
	i386/linux
Message-ID: <200810191002.m9JA2Q5N040016@svn.freebsd.org>

Author: kib
Date: Sun Oct 19 10:02:26 2008
New Revision: 184058
URL: http://svn.freebsd.org/changeset/base/184058

Log:
  Correctly fill siginfo for the signals delivered by linux tkill/tgkill.
  It is required for async cancellation to work.
  
  Fix PROC_LOCK leak in linux_tgkill when signal delivery attempt is made
  to not linux process.
  
  Do not call em_find(p, ...) with p unlocked.
  
  Move common code for linux_tkill() and linux_tgkill() into
  linux_do_tkill().
  
  Change linux siginfo_t definition to match actual linux one. Extend
  uid fields to 4 bytes from 2. The extension does not change structure
  layout and is binary compatible with previous definition, because i386
  is little endian, and each uid field has 2 byte padding after it.
  
  Reported by:	Nicolas Joly 
  Submitted by:	dchangin
  MFC after:	1 month

Modified:
  head/sys/amd64/linux32/linux.h
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/compat/linux/linux_signal.c
  head/sys/compat/linux/linux_signal.h
  head/sys/i386/linux/linux.h
  head/sys/i386/linux/linux_sysvec.c

Modified: head/sys/amd64/linux32/linux.h
==============================================================================
--- head/sys/amd64/linux32/linux.h	Sun Oct 19 09:45:29 2008	(r184057)
+++ head/sys/amd64/linux32/linux.h	Sun Oct 19 10:02:26 2008	(r184058)
@@ -86,6 +86,8 @@ typedef l_long		l_suseconds_t;
 typedef l_long		l_time_t;
 typedef l_uint		l_uid_t;
 typedef l_ushort	l_uid16_t;
+typedef l_int		l_timer_t;
+typedef l_int		l_mqd_t;
 
 typedef struct {
 	l_int		val[2];
@@ -399,10 +401,10 @@ struct l_ucontext {
 #define	LINUX_SI_MAX_SIZE	128
 #define	LINUX_SI_PAD_SIZE	((LINUX_SI_MAX_SIZE/sizeof(l_int)) - 3)
 
-union l_sigval {
+typedef union l_sigval {
 	l_int		sival_int;
 	l_uintptr_t	sival_ptr;
-};
+} l_sigval_t;
 
 typedef struct l_siginfo {
 	l_int		lsi_signo;
@@ -413,23 +415,26 @@ typedef struct l_siginfo {
 
 		struct {
 			l_pid_t		_pid;
-			l_uid16_t	_uid;
+			l_uid_t		_uid;
 		} __packed _kill;
 
 		struct {
-			l_uint		_timer1;
-			l_uint		_timer2;
+			l_timer_t	_tid;
+			l_int		_overrun;
+			char		_pad[sizeof(l_uid_t) - sizeof(l_int)];
+			l_sigval_t	_sigval;
+			l_int		_sys_private;
 		} __packed _timer;
 
 		struct {
 			l_pid_t		_pid;		/* sender's pid */
-			l_uid16_t	_uid;		/* sender's uid */
-			union l_sigval _sigval;
+			l_uid_t		_uid;		/* sender's uid */
+			l_sigval_t	_sigval;
 		} __packed _rt;
 
 		struct {
 			l_pid_t		_pid;		/* which child */
-			l_uid16_t	_uid;		/* sender's uid */
+			l_uid_t		_uid;		/* sender's uid */
 			l_int		_status;	/* exit code */
 			l_clock_t	_utime;
 			l_clock_t	_stime;
@@ -440,7 +445,7 @@ typedef struct l_siginfo {
 		} __packed _sigfault;
 
 		struct {
-			l_int		_band;	/* POLL_IN,POLL_OUT,POLL_MSG */
+			l_long		_band;	/* POLL_IN,POLL_OUT,POLL_MSG */
 			l_int		_fd;
 		} __packed _sigpoll;
 	} _sifields;
@@ -448,6 +453,9 @@ typedef struct l_siginfo {
 
 #define	lsi_pid		_sifields._kill._pid
 #define	lsi_uid		_sifields._kill._uid
+#define	lsi_tid		_sifields._timer._tid
+#define	lsi_overrun	_sifields._timer._overrun
+#define	lsi_sys_private	_sifields._timer._sys_private
 #define	lsi_status	_sifields._sigchld._status
 #define	lsi_utime	_sifields._sigchld._utime
 #define	lsi_stime	_sifields._sigchld._stime
@@ -860,9 +868,6 @@ struct l_user_desc {
 #define	LINUX_CLOCK_REALTIME_HR		4
 #define	LINUX_CLOCK_MONOTONIC_HR	5
 
-typedef int l_timer_t;
-typedef int l_mqd_t;
-
 #define	LINUX_CLONE_VM			0x00000100
 #define	LINUX_CLONE_FS			0x00000200
 #define	LINUX_CLONE_FILES		0x00000400

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==============================================================================
--- head/sys/amd64/linux32/linux32_sysvec.c	Sun Oct 19 09:45:29 2008	(r184057)
+++ head/sys/amd64/linux32/linux32_sysvec.c	Sun Oct 19 10:02:26 2008	(r184058)
@@ -334,9 +334,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo
 	frame.sf_ucontext = PTROUT(&fp->sf_sc);
 
 	/* Fill in POSIX parts */
-	frame.sf_si.lsi_signo = sig;
-	frame.sf_si.lsi_code = code;
-	frame.sf_si.lsi_addr = PTROUT(ksi->ksi_addr);
+	ksiginfo_to_lsiginfo(ksi, &frame.sf_si, sig);
 
 	/*
 	 * Build the signal context to be used by sigreturn.

Modified: head/sys/compat/linux/linux_signal.c
==============================================================================
--- head/sys/compat/linux/linux_signal.c	Sun Oct 19 09:45:29 2008	(r184057)
+++ head/sys/compat/linux/linux_signal.c	Sun Oct 19 10:02:26 2008	(r184058)
@@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+
 #include "opt_compat.h"
 
 #ifdef COMPAT_LINUX32
@@ -535,45 +537,75 @@ linux_kill(struct thread *td, struct lin
 	return (kill(td, &tmp));
 }
 
-int
-linux_tgkill(struct thread *td, struct linux_tgkill_args *args)
+static int
+linux_do_tkill(struct thread *td, l_int tgid, l_int pid, l_int signum)
 {
-   	struct linux_emuldata *em;
-	struct linux_kill_args ka;
+	struct proc *proc = td->td_proc;
+	struct linux_emuldata *em;
 	struct proc *p;
+	ksiginfo_t ksi;
+	int error;
 
-#ifdef DEBUG
-	if (ldebug(tgkill))
-		printf(ARGS(tgkill, "%d, %d, %d"), args->tgid, args->pid, args->sig);
-#endif
-
-	ka.pid = args->pid;
-	ka.signum = args->sig;
+	AUDIT_ARG(signum, signum);
+	AUDIT_ARG(pid, pid);
 
-	if (args->tgid == -1)
-	   	return linux_kill(td, &ka);
+	/*
+	 * Allow signal 0 as a means to check for privileges
+	 */
+	if (!LINUX_SIG_VALID(signum) && signum != 0)
+		return (EINVAL);
 
-	if ((p = pfind(args->pid)) == NULL)
-	      	return ESRCH;
+	if (signum > 0 && signum <= LINUX_SIGTBLSZ)
+		signum = linux_to_bsd_signal[_SIG_IDX(signum)];
 
-	if (p->p_sysent != &elf_linux_sysvec)
-		return ESRCH;
+	if ((p = pfind(pid)) == NULL) {
+		if ((p = zpfind(pid)) == NULL)
+			return (ESRCH);
+	}
 
-	PROC_UNLOCK(p);
+	AUDIT_ARG(process, p);
+	error = p_cansignal(td, p, signum);
+	if (error)
+		goto out;
 
+	error = ESRCH;
 	em = em_find(p, EMUL_DONTLOCK);
 
 	if (em == NULL) {
 #ifdef DEBUG
-		printf("emuldata not found in tgkill.\n");
+		printf("emuldata not found in do_tkill.\n");
 #endif
-		return ESRCH;
+		goto out;
 	}
+	if (tgid > 0 && em->shared->group_pid != tgid)
+		goto out;
+
+	ksiginfo_init(&ksi);
+	ksi.ksi_signo = signum;
+	ksi.ksi_code = LINUX_SI_TKILL;
+	ksi.ksi_errno = 0;
+	ksi.ksi_pid = proc->p_pid;
+	ksi.ksi_uid = proc->p_ucred->cr_ruid;
 
-	if (em->shared->group_pid != args->tgid)
-	   	return ESRCH;
+	error = tdsignal(p, NULL, ksi.ksi_signo, &ksi);
 
-	return linux_kill(td, &ka);
+out:
+	PROC_UNLOCK(p);
+	return (error);
+}
+
+int
+linux_tgkill(struct thread *td, struct linux_tgkill_args *args)
+{
+
+#ifdef DEBUG
+	if (ldebug(tgkill))
+		printf(ARGS(tgkill, "%d, %d, %d"), args->tgid, args->pid, args->sig);
+#endif
+	if (args->pid <= 0 || args->tgid <=0)
+		return (EINVAL);
+
+	return (linux_do_tkill(td, args->tgid, args->pid, args->sig));
 }
 
 int
@@ -583,6 +615,39 @@ linux_tkill(struct thread *td, struct li
 	if (ldebug(tkill))
 		printf(ARGS(tkill, "%i, %i"), args->tid, args->sig);
 #endif
+	if (args->tid <= 0)
+		return (EINVAL);
+
+	return (linux_do_tkill(td, 0, args->tid, args->sig));
+}
+
+void
+ksiginfo_to_lsiginfo(ksiginfo_t *ksi, l_siginfo_t *lsi, l_int sig)
+{
+
+	lsi->lsi_signo = sig;
+	lsi->lsi_code = ksi->ksi_code;
 
-	return (linux_kill(td, (struct linux_kill_args *) args));
+	switch (sig) {
+	case LINUX_SIGPOLL:
+		/* XXX si_fd? */
+		lsi->lsi_band = ksi->ksi_band;
+		break;
+	case LINUX_SIGCHLD:
+		lsi->lsi_pid = ksi->ksi_pid;
+		lsi->lsi_uid = ksi->ksi_uid;
+		lsi->lsi_status = ksi->ksi_status;
+		break;
+	case LINUX_SIGBUS:
+	case LINUX_SIGILL:
+	case LINUX_SIGFPE:
+	case LINUX_SIGSEGV:
+		lsi->lsi_addr = PTROUT(ksi->ksi_addr);
+		break;
+	default:
+		/* XXX SI_TIMER etc... */
+		lsi->lsi_pid = ksi->ksi_pid;
+		lsi->lsi_uid = ksi->ksi_uid;
+		break;
+	}
 }

Modified: head/sys/compat/linux/linux_signal.h
==============================================================================
--- head/sys/compat/linux/linux_signal.h	Sun Oct 19 09:45:29 2008	(r184057)
+++ head/sys/compat/linux/linux_signal.h	Sun Oct 19 10:02:26 2008	(r184058)
@@ -31,9 +31,12 @@
 #ifndef _LINUX_SIGNAL_H_
 #define _LINUX_SIGNAL_H_
 
+#define	LINUX_SI_TKILL		-6;
+
 void linux_to_bsd_sigset(l_sigset_t *, sigset_t *);
 void bsd_to_linux_sigset(sigset_t *, l_sigset_t *);
 int linux_do_sigaction(struct thread *, int, l_sigaction_t *, l_sigaction_t *);
+void ksiginfo_to_lsiginfo(ksiginfo_t *ksi, l_siginfo_t *lsi, l_int sig);
 
 #define LINUX_SIG_VALID(sig)	((sig) <= LINUX_NSIG && (sig) > 0)
 

Modified: head/sys/i386/linux/linux.h
==============================================================================
--- head/sys/i386/linux/linux.h	Sun Oct 19 09:45:29 2008	(r184057)
+++ head/sys/i386/linux/linux.h	Sun Oct 19 10:02:26 2008	(r184058)
@@ -80,6 +80,8 @@ typedef l_long		l_suseconds_t;
 typedef l_long		l_time_t;
 typedef l_uint		l_uid_t;
 typedef l_ushort	l_uid16_t;
+typedef l_int		l_timer_t;
+typedef l_int		l_mqd_t;
 
 typedef struct {
 	l_int		val[2];
@@ -374,6 +376,11 @@ struct l_ucontext {
 #define	LINUX_SI_MAX_SIZE	128
 #define	LINUX_SI_PAD_SIZE	((LINUX_SI_MAX_SIZE/sizeof(l_int)) - 3)
 
+typedef union l_sigval {
+	l_int		sival_int;
+	l_uintptr_t	sival_ptr;
+} l_sigval_t;
+
 typedef struct l_siginfo {
 	l_int		lsi_signo;
 	l_int		lsi_errno;
@@ -383,34 +390,37 @@ typedef struct l_siginfo {
 
 		struct {
 			l_pid_t		_pid;
-			l_uid16_t	_uid;
+			l_uid_t		_uid;
 		} _kill;
 
 		struct {
-			l_uint		_timer1;
-			l_uint		_timer2;
+			l_timer_t	_tid;
+			l_int		_overrun;
+			char		_pad[sizeof(l_uid_t) - sizeof(l_int)];
+			l_sigval_t	_sigval;
+			l_int		_sys_private;
 		} _timer;
 
 		struct {
 			l_pid_t		_pid;		/* sender's pid */
-			l_uid16_t	_uid;		/* sender's uid */
-			union sigval _sigval;
+			l_uid_t		_uid;		/* sender's uid */
+			l_sigval_t	_sigval;
 		} _rt;
 
 		struct {
 			l_pid_t		_pid;		/* which child */
-			l_uid16_t	_uid;		/* sender's uid */
+			l_uid_t		_uid;		/* sender's uid */
 			l_int		_status;	/* exit code */
 			l_clock_t	_utime;
 			l_clock_t	_stime;
 		} _sigchld;
 
 		struct {
-			void		*_addr;	/* Faulting insn/memory ref. */
+			l_uintptr_t	_addr;	/* Faulting insn/memory ref. */
 		} _sigfault;
 
 		struct {
-			l_int		_band;	/* POLL_IN,POLL_OUT,POLL_MSG */
+			l_long		_band;	/* POLL_IN,POLL_OUT,POLL_MSG */
 			l_int		_fd;
 		} _sigpoll;
 	} _sifields;
@@ -418,6 +428,9 @@ typedef struct l_siginfo {
 
 #define	lsi_pid		_sifields._kill._pid
 #define	lsi_uid		_sifields._kill._uid
+#define	lsi_tid		_sifields._timer._tid
+#define	lsi_overrun	_sifields._timer._overrun
+#define	lsi_sys_private	_sifields._timer._sys_private
 #define	lsi_status	_sifields._sigchld._status
 #define	lsi_utime	_sifields._sigchld._utime
 #define	lsi_stime	_sifields._sigchld._stime
@@ -825,9 +838,6 @@ struct l_desc_struct {
 #define	LINUX_CLOCK_REALTIME_HR		4
 #define	LINUX_CLOCK_MONOTONIC_HR	5
 
-typedef int l_timer_t;
-typedef int l_mqd_t;
-
 #define	LINUX_CLONE_VM			0x00000100
 #define	LINUX_CLONE_FS			0x00000200
 #define	LINUX_CLONE_FILES		0x00000400

Modified: head/sys/i386/linux/linux_sysvec.c
==============================================================================
--- head/sys/i386/linux/linux_sysvec.c	Sun Oct 19 09:45:29 2008	(r184057)
+++ head/sys/i386/linux/linux_sysvec.c	Sun Oct 19 10:02:26 2008	(r184058)
@@ -323,9 +323,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo
 	frame.sf_ucontext = &fp->sf_sc;
 
 	/* Fill in POSIX parts */
-	frame.sf_si.lsi_signo = sig;
-	frame.sf_si.lsi_code = code;
-	frame.sf_si.lsi_addr = ksi->ksi_addr;
+	ksiginfo_to_lsiginfo(ksi, &frame.sf_si, sig);
 
 	/*
 	 * Build the signal context to be used by sigreturn.
From delphij at FreeBSD.org  Sun Oct 19 10:11:35 2008
From: delphij at FreeBSD.org (Xin LI)
Date: Sun Oct 19 10:11:47 2008
Subject: svn commit: r184059 - head/lib/libc/string
Message-ID: <200810191011.m9JABZgJ040210@svn.freebsd.org>

Author: delphij
Date: Sun Oct 19 10:11:35 2008
New Revision: 184059
URL: http://svn.freebsd.org/changeset/base/184059

Log:
   - License change to a less restrictive one;
   - ANSIfy;
   - Convert do {} while loop -> while {} for clarity;
   - Sync RCS ID with OpenBSD;
  
  Obtained from:	OpenBSD

Modified:
  head/lib/libc/string/strlcpy.c

Modified: head/lib/libc/string/strlcpy.c
==============================================================================
--- head/lib/libc/string/strlcpy.c	Sun Oct 19 10:02:26 2008	(r184058)
+++ head/lib/libc/string/strlcpy.c	Sun Oct 19 10:11:35 2008	(r184059)
@@ -1,35 +1,21 @@
-/*	$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $	*/
+/*	$OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $	*/
 
 /*
  * Copyright (c) 1998 Todd C. Miller 
- * All rights reserved.
  *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
  *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $";
-#endif /* LIBC_SCCS and not lint */
 #include 
 __FBSDID("$FreeBSD$");
 
@@ -42,21 +28,18 @@ __FBSDID("$FreeBSD$");
  * Returns strlen(src); if retval >= siz, truncation occurred.
  */
 size_t
-strlcpy(dst, src, siz)
-	char *dst;
-	const char *src;
-	size_t siz;
+strlcpy(char *dst, const char *src, size_t siz)
 {
 	char *d = dst;
 	const char *s = src;
 	size_t n = siz;
 
 	/* Copy as many bytes as will fit */
-	if (n != 0 && --n != 0) {
-		do {
-			if ((*d++ = *s++) == 0)
+	if (n != 0) {
+		while (--n != 0) {
+			if ((*d++ = *s++) == '\0')
 				break;
-		} while (--n != 0);
+		}
 	}
 
 	/* Not enough room in dst, add NUL and traverse rest of src */
From kib at FreeBSD.org  Sun Oct 19 11:13:49 2008
From: kib at FreeBSD.org (Konstantin Belousov)
Date: Sun Oct 19 11:14:01 2008
Subject: svn commit: r184060 - head/sys/kern
Message-ID: <200810191113.m9JBDnDM042466@svn.freebsd.org>

Author: kib
Date: Sun Oct 19 11:13:49 2008
New Revision: 184060
URL: http://svn.freebsd.org/changeset/base/184060

Log:
  Ktr(9) stores format string and arguments in the event circular buffer,
  not the string formatted at the time of CTRX() call. Stack_ktr(9) uses
  an on-stack buffer for the symbol name, that is supplied as an argument
  to ktr. As result, stack_ktr() traces show garbage or cause page faults.
  
  Fix stack_ktr() by using pointer to module symbol table that is supposed
  to have a longer lifetime.
  
  Tested by:	pho
  MFC after:	1 week

Modified:
  head/sys/kern/subr_stack.c

Modified: head/sys/kern/subr_stack.c
==============================================================================
--- head/sys/kern/subr_stack.c	Sun Oct 19 10:11:35 2008	(r184059)
+++ head/sys/kern/subr_stack.c	Sun Oct 19 11:13:49 2008	(r184060)
@@ -45,8 +45,7 @@ static MALLOC_DEFINE(M_STACK, "stack", "
 static void stack_symbol(vm_offset_t pc, char *namebuf, u_int buflen,
 	    long *offset);
 #ifdef DDB
-static void stack_symbol_ddb(vm_offset_t pc, char *namebuf, u_int buflen,
-	    long *offset);
+static void stack_symbol_ddb(vm_offset_t pc, const char **name, long *offset);
 #endif
 
 struct stack *
@@ -109,16 +108,15 @@ stack_print(struct stack *st)
 void
 stack_print_ddb(struct stack *st)
 {
-	char namebuf[64];
+	const char *name;
 	long offset;
 	int i;
 
 	KASSERT(st->depth <= STACK_MAX, ("bogus stack"));
 	for (i = 0; i < st->depth; i++) {
-		stack_symbol_ddb(st->pcs[i], namebuf, sizeof(namebuf),
-		    &offset);
+		stack_symbol_ddb(st->pcs[i], &name, &offset);
 		printf("#%d %p at %s+%#lx\n", i, (void *)st->pcs[i],
-		    namebuf, offset);
+		    name, offset);
 	}
 }
 #endif
@@ -146,16 +144,15 @@ stack_sbuf_print(struct sbuf *sb, struct
 void
 stack_sbuf_print_ddb(struct sbuf *sb, struct stack *st)
 {
-	char namebuf[64];
+	const char *name;
 	long offset;
 	int i;
 
 	KASSERT(st->depth <= STACK_MAX, ("bogus stack"));
 	for (i = 0; i < st->depth; i++) {
-		stack_symbol_ddb(st->pcs[i], namebuf, sizeof(namebuf),
-		    &offset);
+		stack_symbol_ddb(st->pcs[i], &name, &offset);
 		sbuf_printf(sb, "#%d %p at %s+%#lx\n", i, (void *)st->pcs[i],
-		    namebuf, offset);
+		    name, offset);
 	}
 }
 
@@ -164,7 +161,7 @@ void
 stack_ktr(u_int mask, const char *file, int line, struct stack *st, u_int depth,
     int cheap)
 {
-	char namebuf[64];
+	const char *name;
 	long offset;
 	int i;
 
@@ -187,10 +184,9 @@ stack_ktr(u_int mask, const char *file, 
 		if (depth == 0 || st->depth < depth)
 			depth = st->depth;
 		for (i = 0; i < depth; i++) {
-			stack_symbol_ddb(st->pcs[i], namebuf,
-			    sizeof(namebuf), &offset);
+			stack_symbol_ddb(st->pcs[i], &name, &offset);
 			ktr_tracepoint(mask, file, line, "#%d %p at %s+%#lx",
-			    i, st->pcs[i], (u_long)namebuf, offset, 0, 0);
+			    i, st->pcs[i], (u_long)name, offset, 0, 0);
 		}
 	}
 }
@@ -214,13 +210,21 @@ stack_symbol(vm_offset_t pc, char *nameb
 
 #ifdef DDB
 static void
-stack_symbol_ddb(vm_offset_t pc, char *namebuf, u_int buflen, long *offset)
+stack_symbol_ddb(vm_offset_t pc, const char **name, long *offset)
 {
+	linker_symval_t symval;
+	c_linker_sym_t sym;
 
-	if (linker_ddb_search_symbol_name((caddr_t)pc, namebuf, buflen,
-	    offset) != 0) {
-		*offset = 0;
-		strlcpy(namebuf, "??", buflen);
-	};
+	if (linker_ddb_search_symbol((caddr_t)pc, &sym, offset) != 0)
+		goto out;
+	if (linker_ddb_symbol_values(sym, &symval) != 0)
+		goto out;
+	if (symval.name != NULL) {
+		*name = symval.name;
+		return;
+	}
+ out:
+	*offset = 0;
+	*name = "??";
 }
 #endif
From rdivacky at FreeBSD.org  Sun Oct 19 12:56:54 2008
From: rdivacky at FreeBSD.org (Roman Divacky)
Date: Sun Oct 19 12:57:00 2008
Subject: svn commit: r184058 - in head/sys: amd64/linux32 compat/linux
	i386/linux
In-Reply-To: <200810191002.m9JA2Q5N040016@svn.freebsd.org>
References: <200810191002.m9JA2Q5N040016@svn.freebsd.org>
Message-ID: <20081019124054.GA25779@freebsd.org>

On Sun, Oct 19, 2008 at 10:02:26AM +0000, Konstantin Belousov wrote:
> Author: kib
> Date: Sun Oct 19 10:02:26 2008
> New Revision: 184058
> URL: http://svn.freebsd.org/changeset/base/184058
> 
> Log:
>   Correctly fill siginfo for the signals delivered by linux tkill/tgkill.
>   It is required for async cancellation to work.
>   
>   Fix PROC_LOCK leak in linux_tgkill when signal delivery attempt is made
>   to not linux process.
>   
>   Do not call em_find(p, ...) with p unlocked.
>   
>   Move common code for linux_tkill() and linux_tgkill() into
>   linux_do_tkill().
>   
>   Change linux siginfo_t definition to match actual linux one. Extend
>   uid fields to 4 bytes from 2. The extension does not change structure
>   layout and is binary compatible with previous definition, because i386
>   is little endian, and each uid field has 2 byte padding after it.
   
does it fix the test case Nicolas provided? It didnt for me when I tried
this patch...

>   Reported by:	Nicolas Joly 

might be of some interest for someone... njoly of netbsd :)
From kostikbel at gmail.com  Sun Oct 19 13:13:20 2008
From: kostikbel at gmail.com (Kostik Belousov)
Date: Sun Oct 19 13:13:27 2008
Subject: svn commit: r184058 - in head/sys: amd64/linux32 compat/linux
	i386/linux
In-Reply-To: <20081019124054.GA25779@freebsd.org>
References: <200810191002.m9JA2Q5N040016@svn.freebsd.org>
	<20081019124054.GA25779@freebsd.org>
Message-ID: <20081019124711.GR7782@deviant.kiev.zoral.com.ua>

On Sun, Oct 19, 2008 at 02:40:54PM +0200, Roman Divacky wrote:
> On Sun, Oct 19, 2008 at 10:02:26AM +0000, Konstantin Belousov wrote:
> > Author: kib
> > Date: Sun Oct 19 10:02:26 2008
> > New Revision: 184058
> > URL: http://svn.freebsd.org/changeset/base/184058
> > 
> > Log:
> >   Correctly fill siginfo for the signals delivered by linux tkill/tgkill.
> >   It is required for async cancellation to work.
> >   
> >   Fix PROC_LOCK leak in linux_tgkill when signal delivery attempt is made
> >   to not linux process.
> >   
> >   Do not call em_find(p, ...) with p unlocked.
> >   
> >   Move common code for linux_tkill() and linux_tgkill() into
> >   linux_do_tkill().
> >   
> >   Change linux siginfo_t definition to match actual linux one. Extend
> >   uid fields to 4 bytes from 2. The extension does not change structure
> >   layout and is binary compatible with previous definition, because i386
> >   is little endian, and each uid field has 2 byte padding after it.
>    
> does it fix the test case Nicolas provided? It didnt for me when I tried
> this patch...
As far as I got it from conversation with Dmitry, cancellation still does
not work. This patch is a required cleanup anyway.

> 
> >   Reported by:	Nicolas Joly 
> 
> might be of some interest for someone... njoly of netbsd :)
Point taken.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20081019/1a77c7e4/attachment.pgp
From simon at FreeBSD.org  Sun Oct 19 17:19:42 2008
From: simon at FreeBSD.org (Simon L. Nielsen)
Date: Sun Oct 19 17:19:49 2008
Subject: svn commit: r184061 - head/share/man/man4
Message-ID: <200810191719.m9JHJglD048674@svn.freebsd.org>

Author: simon
Date: Sun Oct 19 17:19:42 2008
New Revision: 184061
URL: http://svn.freebsd.org/changeset/base/184061

Log:
  Remove trailing comma in SEE ALSO section.

Modified:
  head/share/man/man4/u3g.4

Modified: head/share/man/man4/u3g.4
==============================================================================
--- head/share/man/man4/u3g.4	Sun Oct 19 11:13:49 2008	(r184060)
+++ head/share/man/man4/u3g.4	Sun Oct 19 17:19:42 2008	(r184061)
@@ -91,7 +91,7 @@ hidden, unless the machine was booted in
 .Sh SEE ALSO
 .Xr tty 4 ,
 .Xr ucom 4 ,
-.Xr usb 4 ,
+.Xr usb 4
 .Sh HISTORY
 The
 .Nm
From marcel at FreeBSD.org  Sun Oct 19 20:14:49 2008
From: marcel at FreeBSD.org (Marcel Moolenaar)
Date: Sun Oct 19 20:15:01 2008
Subject: svn commit: r184062 - head/sys/ia64/ia64
Message-ID: <200810192014.m9JKEnCo051658@svn.freebsd.org>

Author: marcel
Date: Sun Oct 19 20:14:48 2008
New Revision: 184062
URL: http://svn.freebsd.org/changeset/base/184062

Log:
  Atomically increment the number of awoken APs as all APs will
  be unleashed here.
  
  Pointed out by: christian.kandeler@hob.de

Modified:
  head/sys/ia64/ia64/mp_machdep.c

Modified: head/sys/ia64/ia64/mp_machdep.c
==============================================================================
--- head/sys/ia64/ia64/mp_machdep.c	Sun Oct 19 17:19:42 2008	(r184061)
+++ head/sys/ia64/ia64/mp_machdep.c	Sun Oct 19 20:14:48 2008	(r184062)
@@ -125,7 +125,7 @@ ia64_ap_startup(void)
 	ia64_mca_save_state(SAL_INFO_MCA);
 	ia64_mca_save_state(SAL_INFO_CMC);
 
-	ap_awake++;
+	atomic_add_int(&ap_awake, 1);
 	while (!smp_started)
 		cpu_spinwait();
 
From sam at FreeBSD.org  Sun Oct 19 21:34:49 2008
From: sam at FreeBSD.org (Sam Leffler)
Date: Sun Oct 19 21:35:00 2008
Subject: svn commit: r184063 - head/sys/dev/ath
Message-ID: <200810192134.m9JLYnxd052988@svn.freebsd.org>

Author: sam
Date: Sun Oct 19 21:34:49 2008
New Revision: 184063
URL: http://svn.freebsd.org/changeset/base/184063

Log:
  fix static key wep; r183248 caused drivers to be called for keys to be
  assigned to slots in the global key table but ath_key_alloc was not
  updated to handle that

Modified:
  head/sys/dev/ath/if_ath.c

Modified: head/sys/dev/ath/if_ath.c
==============================================================================
--- head/sys/dev/ath/if_ath.c	Sun Oct 19 20:14:48 2008	(r184062)
+++ head/sys/dev/ath/if_ath.c	Sun Oct 19 21:34:49 2008	(r184063)
@@ -2403,7 +2403,8 @@ ath_key_alloc(struct ieee80211vap *vap, 
 	 * it permits us to support multiple users for adhoc and/or
 	 * multi-station operation.
 	 */
-	if ((k->wk_flags & IEEE80211_KEY_GROUP) && !sc->sc_mcastkey) {
+	if (k->wk_keyix != IEEE80211_KEYIX_NONE ||	/* global key */
+	    ((k->wk_flags & IEEE80211_KEY_GROUP) && !sc->sc_mcastkey)) {
 		if (!(&vap->iv_nw_keys[0] <= k &&
 		      k < &vap->iv_nw_keys[IEEE80211_WEP_NKID])) {
 			/* should not happen */
From davidxu at FreeBSD.org  Mon Oct 20 02:37:54 2008
From: davidxu at FreeBSD.org (David Xu)
Date: Mon Oct 20 02:38:05 2008
Subject: svn commit: r184067 - head/sys/kern
Message-ID: <200810200237.m9K2brwF058086@svn.freebsd.org>

Author: davidxu
Date: Mon Oct 20 02:37:53 2008
New Revision: 184067
URL: http://svn.freebsd.org/changeset/base/184067

Log:
  In realtimer_delete(), clear timer's value and interval to tell
  realtimer_expire() to not rearm the timer, otherwise there is a chance
  that a callout will be left there and be tiggered in future unexpectly.
  
  Bug reported by: tegge@

Modified:
  head/sys/kern/kern_time.c

Modified: head/sys/kern/kern_time.c
==============================================================================
--- head/sys/kern/kern_time.c	Mon Oct 20 01:46:54 2008	(r184066)
+++ head/sys/kern/kern_time.c	Mon Oct 20 02:37:53 2008	(r184067)
@@ -1242,6 +1242,12 @@ realtimer_delete(struct itimer *it)
 {
 	mtx_assert(&it->it_mtx, MA_OWNED);
 	
+	/*
+	 * clear timer's value and interval to tell realtimer_expire
+	 * to not rearm the timer.
+	 */
+	timespecclear(&it->it_time.it_value);
+	timespecclear(&it->it_time.it_interval);
 	ITIMER_UNLOCK(it);
 	callout_drain(&it->it_callout);
 	ITIMER_LOCK(it);
@@ -1391,9 +1397,11 @@ realtimer_expire(void *arg)
 			callout_reset(&it->it_callout, tvtohz(&tv),
 				 realtimer_expire, it);
 		}
+		itimer_enter(it);
 		ITIMER_UNLOCK(it);
 		itimer_fire(it);
 		ITIMER_LOCK(it);
+		itimer_leave(it);
 	} else if (timespecisset(&it->it_time.it_value)) {
 		ts = it->it_time.it_value;
 		timespecsub(&ts, &cts);
From marcel at FreeBSD.org  Mon Oct 20 04:50:48 2008
From: marcel at FreeBSD.org (Marcel Moolenaar)
Date: Mon Oct 20 04:50:54 2008
Subject: svn commit: r184069 - head/sys/geom/part
Message-ID: <200810200450.m9K4olDY060620@svn.freebsd.org>

Author: marcel
Date: Mon Oct 20 04:50:47 2008
New Revision: 184069
URL: http://svn.freebsd.org/changeset/base/184069

Log:
  The active and bootable flags are not part of the type.
  Export the active and bootable flags as attributes in
  the configuration XML and allow them to be manipulated
  with the set/unset commands.
  
  Since libdisk treats the flags as part of the partition
  type, preserve behavior by keeping them included in the
  configuration text.

Modified:
  head/sys/geom/part/g_part_pc98.c

Modified: head/sys/geom/part/g_part_pc98.c
==============================================================================
--- head/sys/geom/part/g_part_pc98.c	Mon Oct 20 04:50:06 2008	(r184068)
+++ head/sys/geom/part/g_part_pc98.c	Mon Oct 20 04:50:47 2008	(r184069)
@@ -45,6 +45,14 @@ __FBSDID("$FreeBSD$");
 
 #include "g_part_if.h"
 
+#define	PC98_MID_BOOTABLE	0x80
+#define	PC98_MID_MASK		0x7f
+#define	PC98_MID_386BSD		0x14
+
+#define	PC98_SID_ACTIVE		0x80
+#define	PC98_SID_MASK		0x7f
+#define	PC98_SID_386BSD		0x44
+
 #define	SECSIZE		512
 
 struct g_part_pc98_table {
@@ -72,8 +80,10 @@ static char *g_part_pc98_name(struct g_p
     char *, size_t);
 static int g_part_pc98_probe(struct g_part_table *, struct g_consumer *);
 static int g_part_pc98_read(struct g_part_table *, struct g_consumer *);
-static const char *g_part_pc98_type(struct g_part_table *, struct g_part_entry *,
-    char *, size_t);
+static int g_part_pc98_setunset(struct g_part_table *, struct g_part_entry *,
+    const char *, unsigned int);
+static const char *g_part_pc98_type(struct g_part_table *,
+    struct g_part_entry *, char *, size_t);
 static int g_part_pc98_write(struct g_part_table *, struct g_consumer *);
 
 static kobj_method_t g_part_pc98_methods[] = {
@@ -87,6 +97,7 @@ static kobj_method_t g_part_pc98_methods
 	KOBJMETHOD(g_part_name,		g_part_pc98_name),
 	KOBJMETHOD(g_part_probe,	g_part_pc98_probe),
 	KOBJMETHOD(g_part_read,		g_part_pc98_read),
+	KOBJMETHOD(g_part_setunset,	g_part_pc98_setunset),
 	KOBJMETHOD(g_part_type,		g_part_pc98_type),
 	KOBJMETHOD(g_part_write,	g_part_pc98_write),
 	{ 0, 0 }
@@ -115,14 +126,17 @@ pc98_parse_type(const char *type, u_char
 		if (type[1] == '\0' || *endp != '\0' || lt <= 0 ||
 		    lt >= 65536)
 			return (EINVAL);
-		*dp_mid = (u_char)lt;
-		*dp_sid = (u_char)(lt >> 8);
+		/* Make sure the active and bootable flags aren't set. */
+		if (lt & ((PC98_SID_ACTIVE << 8) | PC98_MID_BOOTABLE))
+			return (ENOATTR);
+		*dp_mid = (*dp_mid & PC98_MID_BOOTABLE) | (u_char)lt;
+		*dp_sid = (*dp_sid & PC98_SID_ACTIVE) | (u_char)(lt >> 8);
 		return (0);
 	}
 	alias = g_part_alias_name(G_PART_ALIAS_FREEBSD);
 	if (!strcasecmp(type, alias)) {
-		*dp_mid = (u_char)DOSMID_386BSD;
-		*dp_sid = (u_char)DOSSID_386BSD;
+		*dp_mid = (*dp_mid & PC98_MID_BOOTABLE) | PC98_MID_386BSD;
+		*dp_sid = (*dp_sid & PC98_SID_ACTIVE) | PC98_SID_386BSD;
 		return (0);
 	}
 	return (EINVAL);
@@ -176,6 +190,8 @@ g_part_pc98_add(struct g_part_table *bas
 
 	if (baseentry->gpe_deleted)
 		bzero(&entry->ent, sizeof(entry->ent));
+	else
+		entry->ent.dp_mid = entry->ent.dp_sid = 0;
 
 	KASSERT(baseentry->gpe_start <= start, (__func__));
 	KASSERT(baseentry->gpe_end >= start + size - 1, (__func__));
@@ -259,7 +275,13 @@ g_part_pc98_dumpconf(struct g_part_table
 	} else {
 		/* confxml: partition entry information */
 		sbuf_printf(sb, "%s\n", indent, name);
-		sbuf_printf(sb, "%s%u\n", indent, type);
+		if (entry->ent.dp_mid & PC98_MID_BOOTABLE)
+			sbuf_printf(sb, "%sbootable\n",
+			    indent);
+		if (entry->ent.dp_sid & PC98_SID_ACTIVE)
+			sbuf_printf(sb, "%sactive\n", indent);
+		sbuf_printf(sb, "%s%u\n", indent,
+		    type & 0x7f7f);
 	}
 	return (0);
 }
@@ -271,8 +293,8 @@ g_part_pc98_dumpto(struct g_part_table *
 
 	/* Allow dumping to a FreeBSD partition only. */
 	entry = (struct g_part_pc98_entry *)baseentry;
-	return ((entry->ent.dp_mid == DOSMID_386BSD &&
-	    entry->ent.dp_sid == DOSSID_386BSD) ? 1 : 0);
+	return (((entry->ent.dp_mid & PC98_MID_MASK) == PC98_MID_386BSD &&
+	    (entry->ent.dp_sid & PC98_SID_MASK) == PC98_SID_386BSD) ? 1 : 0);
 }
 
 static int
@@ -412,6 +434,54 @@ g_part_pc98_read(struct g_part_table *ba
 	return (0);
 }
 
+static int
+g_part_pc98_setunset(struct g_part_table *table, struct g_part_entry *baseentry,
+    const char *attrib, unsigned int set)
+{
+	struct g_part_entry *iter;
+	struct g_part_pc98_entry *entry;
+	int changed, mid, sid;
+
+	mid = sid = 0;
+	if (strcasecmp(attrib, "active") == 0)
+		sid = 1;
+	else if (strcasecmp(attrib, "bootable") == 0)
+		mid = 1;
+	if (mid == 0 && sid == 0)
+		return (EINVAL);
+
+	LIST_FOREACH(iter, &table->gpt_entry, gpe_entry) {
+		if (iter->gpe_deleted)
+			continue;
+		if (iter != baseentry)
+			continue;
+		changed = 0;
+		entry = (struct g_part_pc98_entry *)iter;
+		if (set) {
+			if (mid && !(entry->ent.dp_mid & PC98_MID_BOOTABLE)) {
+				entry->ent.dp_mid |= PC98_MID_BOOTABLE;
+				changed = 1;
+			}
+			if (sid && !(entry->ent.dp_sid & PC98_SID_ACTIVE)) {
+				entry->ent.dp_sid |= PC98_SID_ACTIVE;
+				changed = 1;
+			}
+		} else {
+			if (mid && (entry->ent.dp_mid & PC98_MID_BOOTABLE)) {
+				entry->ent.dp_mid &= ~PC98_MID_BOOTABLE;
+				changed = 1;
+			}
+			if (sid && (entry->ent.dp_sid & PC98_SID_ACTIVE)) {
+				entry->ent.dp_sid &= ~PC98_SID_ACTIVE;
+				changed = 1;
+			}
+		}
+		if (changed && !iter->gpe_created)
+			iter->gpe_modified = 1;
+	}
+	return (0);
+}
+
 static const char *
 g_part_pc98_type(struct g_part_table *basetable, struct g_part_entry *baseentry, 
     char *buf, size_t bufsz)
@@ -420,8 +490,9 @@ g_part_pc98_type(struct g_part_table *ba
 	u_int type;
 
 	entry = (struct g_part_pc98_entry *)baseentry;
-	type = entry->ent.dp_mid + (entry->ent.dp_sid << 8);
-	if (type == DOSPTYP_386BSD)
+	type = (entry->ent.dp_mid & PC98_MID_MASK) |
+	    ((entry->ent.dp_sid & PC98_SID_MASK) << 8);
+	if (type == (PC98_MID_386BSD | (PC98_SID_386BSD << 8)))
 		return (g_part_alias_name(G_PART_ALIAS_FREEBSD));
 	snprintf(buf, bufsz, "!%d", type);
 	return (buf);
From marcel at FreeBSD.org  Mon Oct 20 05:12:51 2008
From: marcel at FreeBSD.org (Marcel Moolenaar)
Date: Mon Oct 20 05:13:02 2008
Subject: svn commit: r184070 - head/sbin/geom/class/part
Message-ID: <200810200512.m9K5CoPv061024@svn.freebsd.org>

Author: marcel
Date: Mon Oct 20 05:12:50 2008
New Revision: 184070
URL: http://svn.freebsd.org/changeset/base/184070

Log:
  Add support for multiple attributes. This is required for the
  PC98 scheme.

Modified:
  head/sbin/geom/class/part/geom_part.c

Modified: head/sbin/geom/class/part/geom_part.c
==============================================================================
--- head/sbin/geom/class/part/geom_part.c	Mon Oct 20 04:50:47 2008	(r184069)
+++ head/sbin/geom/class/part/geom_part.c	Mon Oct 20 05:12:50 2008	(r184070)
@@ -223,13 +223,20 @@ fmtsize(long double rawsz)
 static const char *
 fmtattrib(struct gprovider *pp)
 {
-	static char buf[64];
-	const char *val;
-
-	val = find_provcfg(pp, "attrib");
-	if (val == NULL)
-		return ("");
-	snprintf(buf, sizeof(buf), " [%s] ", val);
+	static char buf[128];
+	struct gconfig *gc;
+	u_int idx;
+
+	buf[0] = '\0';
+	idx = 0;
+	LIST_FOREACH(gc, &pp->lg_config, lg_config) {
+		if (strcmp(gc->lg_name, "attrib") != 0)
+			continue;
+		idx += snprintf(buf + idx, sizeof(buf) - idx, "%s%s",
+		    (idx == 0) ? " [" : ",", gc->lg_val);
+	}
+	if (idx > 0)
+		snprintf(buf + idx, sizeof(buf) - idx, "] ");
 	return (buf);
 }
 
From kmacy at FreeBSD.org  Mon Oct 20 05:42:38 2008
From: kmacy at FreeBSD.org (Kip Macy)
Date: Mon Oct 20 05:42:50 2008
Subject: svn commit: r184071 - head/sys/i386/xen
Message-ID: <200810200542.m9K5gc7k061544@svn.freebsd.org>

Author: kmacy
Date: Mon Oct 20 05:42:38 2008
New Revision: 184071
URL: http://svn.freebsd.org/changeset/base/184071

Log:
  Import interrupt management defines from latest xenlinux

Modified:
  head/sys/i386/xen/exception.s

Modified: head/sys/i386/xen/exception.s
==============================================================================
--- head/sys/i386/xen/exception.s	Mon Oct 20 05:12:50 2008	(r184070)
+++ head/sys/i386/xen/exception.s	Mon Oct 20 05:42:38 2008	(r184071)
@@ -37,18 +37,37 @@
 #include 
 #include 
 
-
 #include "assym.s"
 
 #define	SEL_RPL_MASK	0x0002
 #define __HYPERVISOR_iret	23
 	
 /* Offsets into shared_info_t. */
+
 #define evtchn_upcall_pending /* 0 */
 #define evtchn_upcall_mask       1
-#define XEN_BLOCK_EVENTS(reg)     movb $1,evtchn_upcall_mask(reg)
-#define XEN_UNBLOCK_EVENTS(reg)   movb $0,evtchn_upcall_mask(reg)
-#define XEN_TEST_PENDING(reg)     testb $0x1,evtchn_upcall_pending(reg)
+
+#define	sizeof_vcpu_shift	6
+
+		
+#ifdef SMP
+#ifdef notyet	
+#define GET_VCPU_INFO		movl TI_cpu(%ebp),reg			; \
+				shl  $sizeof_vcpu_shift,reg		; \
+				addl HYPERVISOR_shared_info,reg
+#else
+#endif	
+
+#define GET_VCPU_INFO(reg)	movl HYPERVISOR_shared_info,reg
+#endif
+
+#define __DISABLE_INTERRUPTS(reg)	movb $1,evtchn_upcall_mask(reg)
+#define __ENABLE_INTERRUPTS(reg)	movb $0,evtchn_upcall_mask(reg)
+#define DISABLE_INTERRUPTS(reg)	GET_VCPU_INFO(reg)			; \
+				__DISABLE_INTERRUPTS(reg)
+#define ENABLE_INTERRUPTS(reg)	GET_VCPU_INFO(reg)			; \
+				__ENABLE_INTERRUPTS(reg)
+#define __TEST_PENDING(reg)	testb $0xFF,evtchn_upcall_pending(reg)
 
 #define POPA \
         popl %edi; \
@@ -163,8 +182,7 @@ call_evtchn_upcall:
 
 	
 hypervisor_callback_pending:
-	movl	HYPERVISOR_shared_info,%esi
-	XEN_BLOCK_EVENTS(%esi)				/*	cli */	
+	DISABLE_INTERRUPTS(%esi)				/*	cli */	
 	jmp	10b
 
 	/*
@@ -338,12 +356,11 @@ doreti_ast:
 	 * interrupts provides sufficient locking even in the SMP case,
 	 * since we will be informed of any new ASTs by an IPI.
 	 */
-	movl	HYPERVISOR_shared_info,%esi
-	XEN_BLOCK_EVENTS(%esi)				/*	cli */
+	DISABLE_INTERRUPTS(%esi)				/*	cli */
 	movl	PCPU(CURTHREAD),%eax
 	testl	$TDF_ASTPENDING | TDF_NEEDRESCHED,TD_FLAGS(%eax)
 	je	doreti_exit
-	XEN_UNBLOCK_EVENTS(%esi)	/* sti */
+	ENABLE_INTERRUPTS(%esi)	/* sti */
 	pushl	%esp			/* pass a pointer to the trapframe */
 	call	ast
 	add	$4,%esp
@@ -357,12 +374,11 @@ doreti_ast:
 	 *	registers.  The fault is handled in trap.c.
 	 */
 doreti_exit:
-	movl	HYPERVISOR_shared_info,%esi
-	XEN_UNBLOCK_EVENTS(%esi) # reenable event callbacks (sti)
+	ENABLE_INTERRUPTS(%esi) # reenable event callbacks (sti)
 
 	.globl	scrit
 scrit:
-	XEN_TEST_PENDING(%esi)
+	__TEST_PENDING(%esi)
         jnz	hypervisor_callback_pending	/* More to go  */
 
 	MEXITCOUNT
From ru at FreeBSD.org  Mon Oct 20 08:44:15 2008
From: ru at FreeBSD.org (Ruslan Ermilov)
Date: Mon Oct 20 08:44:26 2008
Subject: svn commit: r184072 - head/contrib/tcsh
Message-ID: <200810200844.m9K8iEle064707@svn.freebsd.org>

Author: ru
Date: Mon Oct 20 08:44:14 2008
New Revision: 184072
URL: http://svn.freebsd.org/changeset/base/184072

Log:
  Actually fix pty detection for autologout setting.
  (The fix has been submitted upstream.)

Modified:
  head/contrib/tcsh/sh.c
  head/contrib/tcsh/tc.const.c

Modified: head/contrib/tcsh/sh.c
==============================================================================
--- head/contrib/tcsh/sh.c	Mon Oct 20 05:42:38 2008	(r184071)
+++ head/contrib/tcsh/sh.c	Mon Oct 20 08:44:14 2008	(r184072)
@@ -462,7 +462,7 @@ main(int argc, char **argv)
 	    else
 		cp2 = cp;
 	    if (!(((Strncmp(cp2, STRtty, 3) == 0) && Isalpha(cp2[3])) ||
-	          Strstr(cp, STRslptssl) != NULL)) {
+	          Strstr(cp, STRptssl) != NULL)) {
 		if (getenv("DISPLAY") == NULL) {
 		    /* NOT on X window shells */
 		    setcopy(STRautologout, STRdefautologout, VAR_READWRITE);

Modified: head/contrib/tcsh/tc.const.c
==============================================================================
--- head/contrib/tcsh/tc.const.c	Mon Oct 20 05:42:38 2008	(r184071)
+++ head/contrib/tcsh/tc.const.c	Mon Oct 20 08:44:14 2008	(r184072)
@@ -46,7 +46,7 @@ Char STRautomatic[]	= { 'a', 'u', 't', '
 Char STRhangup[]	= { 'h', 'a', 'n', 'g', 'u', 'p', '\0' };
 Char STRaout[]		= { 'a', '.', 'o', 'u', 't', '\0' };
 Char STRtty[]		= { 't', 't', 'y', '\0' };
-Char STRslptssl[]	= { '/', 'p', 't', 's', '/', '\0' };
+Char STRptssl[]		= { 'p', 't', 's', '/', '\0' };
 Char STRany[]		= { 'a', 'n', 'y', '\0' };
 Char STRstatus[]	= { 's', 't', 'a', 't', 'u', 's', '\0' };
 Char STR0[]		= { '0', '\0' };
From kib at FreeBSD.org  Mon Oct 20 10:07:29 2008
From: kib at FreeBSD.org (Konstantin Belousov)
Date: Mon Oct 20 10:07:39 2008
Subject: svn commit: r184073 - head/sys/kern
Message-ID: <200810201007.m9KA7SJQ066155@svn.freebsd.org>

Author: kib
Date: Mon Oct 20 10:07:28 2008
New Revision: 184073
URL: http://svn.freebsd.org/changeset/base/184073

Log:
  In vfs_busy(), lockmgr() cannot legitimately sleep, because code checked
  MNTK_UNMOUNT before, and mnt_mtx is used as interlock. vfs_busy() always
  tries to obtain a shared lock on mnt_lock, the other user is unmount who
  tries to drain it, setting MNTK_UNMOUNT before.
  
  Reviewed by:	tegge, attilio
  Tested by:	pho
  MFC after:	2 weeks

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==============================================================================
--- head/sys/kern/vfs_subr.c	Mon Oct 20 08:44:14 2008	(r184072)
+++ head/sys/kern/vfs_subr.c	Mon Oct 20 10:07:28 2008	(r184073)
@@ -368,7 +368,7 @@ vfs_busy(struct mount *mp, int flags, st
 	}
 	if (interlkp)
 		mtx_unlock(interlkp);
-	lkflags = LK_SHARED | LK_INTERLOCK;
+	lkflags = LK_SHARED | LK_INTERLOCK | LK_NOWAIT;
 	if (lockmgr(&mp->mnt_lock, lkflags, MNT_MTX(mp)))
 		panic("vfs_busy: unexpected lock failure");
 	return (0);
From kib at FreeBSD.org  Mon Oct 20 10:11:33 2008
From: kib at FreeBSD.org (Konstantin Belousov)
Date: Mon Oct 20 10:11:44 2008
Subject: svn commit: r184074 - in head/sys: kern ufs/ffs
Message-ID: <200810201011.m9KABXLf066267@svn.freebsd.org>

Author: kib
Date: Mon Oct 20 10:11:33 2008
New Revision: 184074
URL: http://svn.freebsd.org/changeset/base/184074

Log:
  Assert that v_holdcnt is non-zero before entering lockmgr in vn_lock
  and ffs_lock. This cannot catch situations where holdcnt is incremented
  not by curthread, but I think it is useful.
  
  Reviewed by:	tegge, attilio
  Tested by:	pho
  MFC after:	2 weeks

Modified:
  head/sys/kern/vfs_vnops.c
  head/sys/ufs/ffs/ffs_vnops.c

Modified: head/sys/kern/vfs_vnops.c
==============================================================================
--- head/sys/kern/vfs_vnops.c	Mon Oct 20 10:07:28 2008	(r184073)
+++ head/sys/kern/vfs_vnops.c	Mon Oct 20 10:11:33 2008	(r184074)
@@ -873,6 +873,10 @@ _vn_lock(struct vnode *vp, int flags, ch
 	VNASSERT((flags & LK_TYPE_MASK) != 0, vp,
 	    ("vn_lock called with no locktype."));
 	do {
+#ifdef DEBUG_VFS_LOCKS
+		KASSERT(vp->v_holdcnt != 0,
+		    ("vn_lock %p: zero hold count", vp));
+#endif
 		error = VOP_LOCK1(vp, flags, file, line);
 		flags &= ~LK_INTERLOCK;	/* Interlock is always dropped. */
 		KASSERT((flags & LK_RETRY) == 0 || error == 0,

Modified: head/sys/ufs/ffs/ffs_vnops.c
==============================================================================
--- head/sys/ufs/ffs/ffs_vnops.c	Mon Oct 20 10:07:28 2008	(r184073)
+++ head/sys/ufs/ffs/ffs_vnops.c	Mon Oct 20 10:11:33 2008	(r184074)
@@ -361,6 +361,10 @@ ffs_lock(ap)
 		vp = ap->a_vp;
 		flags = ap->a_flags;
 		for (;;) {
+#ifdef DEBUG_VFS_LOCKS
+			KASSERT(vp->v_holdcnt != 0,
+			    ("ffs_lock %p: zero hold count", vp));
+#endif
 			lkp = vp->v_vnlock;
 			result = _lockmgr_args(lkp, flags, VI_MTX(vp),
 			    LK_WMESG_DEFAULT, LK_PRIO_DEFAULT, LK_TIMO_DEFAULT,
From kostikbel at gmail.com  Mon Oct 20 11:22:30 2008
From: kostikbel at gmail.com (Kostik Belousov)
Date: Mon Oct 20 11:22:36 2008
Subject: svn commit: r184067 - head/sys/kern
In-Reply-To: <200810200237.m9K2brwF058086@svn.freebsd.org>
References: <200810200237.m9K2brwF058086@svn.freebsd.org>
Message-ID: <20081020112225.GX7782@deviant.kiev.zoral.com.ua>

On Mon, Oct 20, 2008 at 02:37:53AM +0000, David Xu wrote:
> Author: davidxu
> Date: Mon Oct 20 02:37:53 2008
> New Revision: 184067
> URL: http://svn.freebsd.org/changeset/base/184067
> 
> Log:
>   In realtimer_delete(), clear timer's value and interval to tell
>   realtimer_expire() to not rearm the timer, otherwise there is a chance
>   that a callout will be left there and be tiggered in future unexpectly.
>   
>   Bug reported by: tegge@
> 
> Modified:
>   head/sys/kern/kern_time.c
Do you plan to MFC this to RELENG_7 ? This seems as a nice fix to have
in upcoming 7.1.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-head/attachments/20081020/89cb9ad0/attachment.pgp
From des at des.no  Mon Oct 20 16:10:25 2008
From: des at des.no (=?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?=)
Date: Mon Oct 20 16:10:31 2008
Subject: svn commit: r183989 - head/lib/libutil
In-Reply-To: <200810172121.m9HLLETA098194@svn.freebsd.org> (Xin LI's message
	of "Fri, 17 Oct 2008 21:21:14 +0000 (UTC)")
References: <200810172121.m9HLLETA098194@svn.freebsd.org>
Message-ID: <86wsg3gscw.fsf@ds4.des.no>

Xin LI  writes:
> Modified: head/lib/libutil/login_times.c
> ==============================================================================
> --- head/lib/libutil/login_times.c	Fri Oct 17 21:14:50 2008	(r183988)
> +++ head/lib/libutil/login_times.c	Fri Oct 17 21:21:14 2008	(r183989)
> @@ -72,8 +72,7 @@ parse_lt(const char * str)
>  	char		buf[64];
>  
>  	/* Make local copy and force lowercase to simplify parsing */
> -	p = strncpy(buf, str, sizeof buf);
> -	buf[sizeof buf - 1] = '\0';
> +	p = strlcpy(buf, str, sizeof buf);
>  	for (i = 0; buf[i]; i++)
>  	    buf[i] = (char)tolower(buf[i]);

This makes absolutely no sense: strncpy() and strlcpy() have different
return types.  The existing code was safe and worked just fine; why
break it?

DES
-- 
Dag-Erling Sm?rgrav - des@des.no
From des at des.no  Mon Oct 20 16:17:47 2008
From: des at des.no (=?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?=)
Date: Mon Oct 20 16:17:58 2008
Subject: svn commit: r183679 - head
In-Reply-To: <200810080131.m981V0HR016984@svn.freebsd.org> (Xin LI's message
	of "Wed, 8 Oct 2008 01:31:00 +0000 (UTC)")
References: <200810080131.m981V0HR016984@svn.freebsd.org>
Message-ID: <86skqrgs0m.fsf@ds4.des.no>

Xin LI  writes:
> Modified: head/UPDATING
> ==============================================================================
> --- head/UPDATING	Tue Oct  7 23:55:32 2008	(r183678)
> +++ head/UPDATING	Wed Oct  8 01:31:00 2008	(r183679)
> @@ -59,6 +59,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8.
>  	option to "ssh-dss,ssh-rsa" in ~/.ssh/config or on the ssh
>  	command line.
>  
> +	Please note that the sequence of keys offered for
> +	authentication has been changed as well.  You may want to
> +	specify IdentityFile in a different order to revert this
> +	behavior.
> +
>  20080713:
>  	The sio(4) driver has been removed from the i386 and amd64
>  	kernel configuration files. This means uart(4) is now the

You should have asked me before committing this - and you should have
mentioned and justified the addition it in the commit message.  As it
is now, the entry gives the impression that this change was an
unfortunate side effect which needs to be worked around by the user,
when in fact it was a conscious and deliberate choice intended to
benefit users.

DES
-- 
Dag-Erling Sm?rgrav - des@des.no
From des at FreeBSD.org  Mon Oct 20 16:48:18 2008
From: des at FreeBSD.org (Dag-Erling Smorgrav)
Date: Mon Oct 20 16:48:25 2008
Subject: svn commit: r184081 - head/lib/libutil
Message-ID: <200810201648.m9KGmIVs075556@svn.freebsd.org>

Author: des
Date: Mon Oct 20 16:48:18 2008
New Revision: 184081
URL: http://svn.freebsd.org/changeset/base/184081

Log:
  include and whitespace cleanup.

Modified:
  head/lib/libutil/login_class.c

Modified: head/lib/libutil/login_class.c
==============================================================================
--- head/lib/libutil/login_class.c	Mon Oct 20 16:44:59 2008	(r184080)
+++ head/lib/libutil/login_class.c	Mon Oct 20 16:48:18 2008	(r184081)
@@ -25,14 +25,16 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
 #include 
-#include 
-#include 
-#include 
 #include 
 #include 
+#include 
 #include 
+#include 
+#include 
+
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -92,7 +94,7 @@ setclassresources(login_cap_t *lc)
 	if (getrlimit(lr->why, &rlim) != 0)
 	    syslog(LOG_ERR, "getting %s resource limit: %m", lr->what);
 	else {
-	    char  	name_cur[40];
+	    char	name_cur[40];
 	    char	name_max[40];
 	    rlim_t	rcur = rlim.rlim_cur;
 	    rlim_t	rmax = rlim.rlim_max;
@@ -104,7 +106,7 @@ setclassresources(login_cap_t *lc)
 	    rmax = (*lr->who)(lc, lr->what, rmax, rmax);
 	    rlim.rlim_cur = (*lr->who)(lc, name_cur, rcur, rcur);
 	    rlim.rlim_max = (*lr->who)(lc, name_max, rmax, rmax);
-    
+
 	    if (setrlimit(lr->why, &rlim) == -1)
 		syslog(LOG_WARNING, "set class '%s' resource limit %s: %m", lc->lc_class, lr->what);
 	}
@@ -534,4 +536,3 @@ setusercontext(login_cap_t *lc, const st
 
     return 0;
 }
-
From des at FreeBSD.org  Mon Oct 20 16:51:43 2008
From: des at FreeBSD.org (Dag-Erling Smorgrav)
Date: Mon Oct 20 16:51:55 2008
Subject: svn commit: r184082 - head/lib/libutil
Message-ID: <200810201651.m9KGphlW075645@svn.freebsd.org>

Author: des
Date: Mon Oct 20 16:51:43 2008
New Revision: 184082
URL: http://svn.freebsd.org/changeset/base/184082

Log:
  Parenthesize return values.

Modified:
  head/lib/libutil/login_class.c

Modified: head/lib/libutil/login_class.c
==============================================================================
--- head/lib/libutil/login_class.c	Mon Oct 20 16:48:18 2008	(r184081)
+++ head/lib/libutil/login_class.c	Mon Oct 20 16:51:43 2008	(r184082)
@@ -187,7 +187,7 @@ substvar(const char * var, const struct 
 	}
     }
 
-    return np;
+    return (np);
 }
 
 
@@ -311,7 +311,7 @@ list2cpuset(const char *list, cpuset_t *
 		case DASH:
 			return (0);
 	}
-	return 1;
+	return (1);
 }
 
 
@@ -370,7 +370,7 @@ setclasscontext(const char *classname, u
 
     rc = lc ? setusercontext(lc, NULL, 0, flags) : -1;
     login_close(lc);
-    return rc;
+    return (rc);
 }
 
 
@@ -400,7 +400,7 @@ setlogincontext(login_cap_t *lc, const s
 	if (flags & LOGIN_SETCPUMASK)
 	    setclasscpumask(lc);
     }
-    return mymask;
+    return (mymask);
 }
 
 
@@ -470,13 +470,13 @@ setusercontext(login_cap_t *lc, const st
 	if (setgid(pwd->pw_gid) != 0) {
 	    syslog(LOG_ERR, "setgid(%lu): %m", (u_long)pwd->pw_gid);
 	    login_close(llc);
-	    return -1;
+	    return (-1);
 	}
 	if (initgroups(pwd->pw_name, pwd->pw_gid) == -1) {
 	    syslog(LOG_ERR, "initgroups(%s,%lu): %m", pwd->pw_name,
 		   (u_long)pwd->pw_gid);
 	    login_close(llc);
-	    return -1;
+	    return (-1);
 	}
     }
 
@@ -490,7 +490,7 @@ setusercontext(login_cap_t *lc, const st
 	    if (mac_from_text(&label, label_string) == -1) {
 		syslog(LOG_ERR, "mac_from_text('%s') for %s: %m",
 		    pwd->pw_name, label_string);
-		    return -1;
+		return (-1);
 	    }
 	    if (mac_set_proc(label) == -1)
 		error = errno;
@@ -500,7 +500,7 @@ setusercontext(login_cap_t *lc, const st
 	    if (error != 0) {
 		syslog(LOG_ERR, "mac_set_proc('%s') for %s: %s",
 		    label_string, pwd->pw_name, strerror(error));
-		return -1;
+		return (-1);
 	    }
 	}
     }
@@ -509,7 +509,7 @@ setusercontext(login_cap_t *lc, const st
     if ((flags & LOGIN_SETLOGIN) && setlogin(pwd->pw_name) != 0) {
 	syslog(LOG_ERR, "setlogin(%s): %m", pwd->pw_name);
 	login_close(llc);
-	return -1;
+	return (-1);
     }
 
     mymask = (flags & LOGIN_SETUMASK) ? umask(LOGIN_DEFUMASK) : 0;
@@ -519,7 +519,7 @@ setusercontext(login_cap_t *lc, const st
     /* This needs to be done after anything that needs root privs */
     if ((flags & LOGIN_SETUSER) && setuid(uid) != 0) {
 	syslog(LOG_ERR, "setuid(%lu): %m", (u_long)uid);
-	return -1;	/* Paranoia again */
+	return (-1);	/* Paranoia again */
     }
 
     /*
@@ -534,5 +534,5 @@ setusercontext(login_cap_t *lc, const st
     if (flags & LOGIN_SETUMASK)
 	umask(mymask);
 
-    return 0;
+    return (0);
 }
From des at FreeBSD.org  Mon Oct 20 16:54:54 2008
From: des at FreeBSD.org (Dag-Erling Smorgrav)
Date: Mon Oct 20 16:55:05 2008
Subject: svn commit: r184083 - head/lib/libutil
Message-ID: <200810201654.m9KGsr7g075743@svn.freebsd.org>

Author: des
Date: Mon Oct 20 16:54:53 2008
New Revision: 184083
URL: http://svn.freebsd.org/changeset/base/184083

Log:
  Style and whitespace.

Modified:
  head/lib/libutil/login_cap.h

Modified: head/lib/libutil/login_cap.h
==============================================================================
--- head/lib/libutil/login_cap.h	Mon Oct 20 16:51:43 2008	(r184082)
+++ head/lib/libutil/login_cap.h	Mon Oct 20 16:54:53 2008	(r184083)
@@ -81,7 +81,7 @@ typedef struct login_time {
 #define LTM_NONE  0x00
 #define LTM_SUN   0x01
 #define LTM_MON   0x02
-#define LTM_TUE   0x04 
+#define LTM_TUE   0x04
 #define LTM_WED   0x08
 #define LTM_THU   0x10
 #define LTM_FRI   0x20
@@ -104,7 +104,8 @@ login_cap_t *login_getclass(const char *
 login_cap_t *login_getpwclass(const struct passwd *);
 login_cap_t *login_getuserclass(const struct passwd *);
 
-const char *login_getcapstr(login_cap_t*, const char *, const char *, const char *);
+const char *login_getcapstr(login_cap_t *, const char *, const char *,
+    const char *);
 const char **login_getcaplist(login_cap_t *, const char *, const char *);
 const char *login_getstyle(login_cap_t *, const char *, const char *);
 rlim_t login_getcaptime(login_cap_t *, const char *, rlim_t, rlim_t);
@@ -114,31 +115,32 @@ const char *login_getpath(login_cap_t *,
 int login_getcapbool(login_cap_t *, const char *, int);
 const char *login_setcryptfmt(login_cap_t *, const char *, const char *);
 
-int setclasscontext(const char*, unsigned int);
-int setusercontext(login_cap_t*, const struct passwd*, uid_t, unsigned int);
+int setclasscontext(const char *, unsigned int);
+int setusercontext(login_cap_t *, const struct passwd *, uid_t, unsigned int);
 void setclassresources(login_cap_t *);
 void setclassenvironment(login_cap_t *, const struct passwd *, int);
 
 /* Most of these functions are deprecated */
-int auth_approve(login_cap_t*, const char*, const char*);
+int auth_approve(login_cap_t *, const char *, const char *);
 int auth_check(const char *, const char *, const char *, const char *, int *);
 void auth_env(void);
-char *auth_mkvalue(const char *n);
-int auth_response(const char *, const char *, const char *, const char *, int *, const char *, const char *);
+char *auth_mkvalue(const char *);
+int auth_response(const char *, const char *, const char *, const char *, int *,
+    const char *, const char *);
 void auth_rmfiles(void);
 int auth_scan(int);
-int auth_script(const char*, ...);
+int auth_script(const char *, ...);
 int auth_script_data(const char *, int, const char *, ...);
 char *auth_valud(const char *);
 int auth_setopt(const char *, const char *);
 void auth_clropts(void);
 
-void auth_checknologin(login_cap_t*);
-int auth_cat(const char*);
+void auth_checknologin(login_cap_t *);
+int auth_cat(const char *);
 
-int auth_ttyok(login_cap_t*, const char *);
-int auth_hostok(login_cap_t*, const char *, char const *);
-int auth_timeok(login_cap_t*, time_t);
+int auth_ttyok(login_cap_t *, const char *);
+int auth_hostok(login_cap_t *, const char *, char const *);
+int auth_timeok(login_cap_t *, time_t);
 
 struct tm;
 
@@ -150,9 +152,11 @@ int in_ltms(const login_time_t *, struct
 
 int login_strinlist(const char **, char const *, int);
 int login_str2inlist(const char **, const char *, const char *, int);
-login_time_t * login_timelist(login_cap_t *, char const *, int *, login_time_t **);
+login_time_t * login_timelist(login_cap_t *, char const *, int *,
+    login_time_t **);
 int login_ttyok(login_cap_t *, const char *, const char *, const char *);
-int login_hostok(login_cap_t *, const char *, const char *, const char *, const char *);
+int login_hostok(login_cap_t *, const char *, const char *, const char *,
+    const char *);
 
 __END_DECLS
 
From des at FreeBSD.org  Mon Oct 20 17:03:06 2008
From: des at FreeBSD.org (Dag-Erling Smorgrav)
Date: Mon Oct 20 17:03:12 2008
Subject: svn commit: r184084 - head/lib/libutil
Message-ID: <200810201703.m9KH36IJ075947@svn.freebsd.org>

Author: des
Date: Mon Oct 20 17:03:05 2008
New Revision: 184084
URL: http://svn.freebsd.org/changeset/base/184084

Log:
  Since setclasscpumask() is not static, assume that it is intended to be
  part of the public API.  Accordingly, add a prototype and document it.

Modified:
  head/lib/libutil/login_cap.h
  head/lib/libutil/login_class.3

Modified: head/lib/libutil/login_cap.h
==============================================================================
--- head/lib/libutil/login_cap.h	Mon Oct 20 16:54:53 2008	(r184083)
+++ head/lib/libutil/login_cap.h	Mon Oct 20 17:03:05 2008	(r184084)
@@ -116,6 +116,7 @@ int login_getcapbool(login_cap_t *, cons
 const char *login_setcryptfmt(login_cap_t *, const char *, const char *);
 
 int setclasscontext(const char *, unsigned int);
+void setclasscpumask(login_cap_t *);
 int setusercontext(login_cap_t *, const struct passwd *, uid_t, unsigned int);
 void setclassresources(login_cap_t *);
 void setclassenvironment(login_cap_t *, const struct passwd *, int);

Modified: head/lib/libutil/login_class.3
==============================================================================
--- head/lib/libutil/login_class.3	Mon Oct 20 16:54:53 2008	(r184083)
+++ head/lib/libutil/login_class.3	Mon Oct 20 17:03:05 2008	(r184084)
@@ -19,11 +19,12 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 28, 1996
+.Dd October 20, 2008
 .Os
 .Dt LOGIN_CLASS 3
 .Sh NAME
 .Nm setclasscontext ,
+.Nm setclasscpumask ,
 .Nm setclassenvironment ,
 .Nm setclassresources ,
 .Nm setusercontext
@@ -35,12 +36,14 @@
 .In login_cap.h
 .Ft int
 .Fn setclasscontext "const char *classname" "unsigned int flags"
-.Ft int
-.Fn setusercontext "login_cap_t *lc" "const struct passwd *pwd" "uid_t uid" "unsigned int flags"
 .Ft void
-.Fn setclassresources "login_cap_t *lc"
+.Fn setclasscpumask "login_cap_t *lc"
 .Ft void
 .Fn setclassenvironment "login_cap_t *lc" "const struct passwd *pwd" "int paths"
+.Ft void
+.Fn setclassresources "login_cap_t *lc"
+.Ft int
+.Fn setusercontext "login_cap_t *lc" "const struct passwd *pwd" "uid_t uid" "unsigned int flags"
 .Sh DESCRIPTION
 These functions provide a higher level interface to the login class
 database than those documented in
@@ -162,7 +165,7 @@ and set the cpu affinity to the specifie
 The string may contain a comma separated list of numbers and/or number
 ranges as handled by the
 .Xr cpuset 1
-utility or the case-insensitive string 
+utility or the case-insensitive string
 .Ql default .
 If the string is
 .Ql default
@@ -182,6 +185,7 @@ are substituted for the user's home dire
 respectively.
 .Pp
 The
+.Fn setclasscpumask ,
 .Fn setclassresources
 and
 .Fn setclassenvironment
From des at FreeBSD.org  Mon Oct 20 17:04:57 2008
From: des at FreeBSD.org (Dag-Erling Smorgrav)
Date: Mon Oct 20 17:05:04 2008
Subject: svn commit: r184085 - head/lib/libutil
Message-ID: <200810201704.m9KH4vfj076017@svn.freebsd.org>

Author: des
Date: Mon Oct 20 17:04:57 2008
New Revision: 184085
URL: http://svn.freebsd.org/changeset/base/184085

Log:
  Unbreak

Modified:
  head/lib/libutil/login_times.c

Modified: head/lib/libutil/login_times.c
==============================================================================
--- head/lib/libutil/login_times.c	Mon Oct 20 17:03:05 2008	(r184084)
+++ head/lib/libutil/login_times.c	Mon Oct 20 17:04:57 2008	(r184085)
@@ -40,7 +40,7 @@ static struct
 {
     { "su", 2, LTM_SUN }, { "mo", 2, LTM_MON }, { "tu", 2, LTM_TUE },
     { "we", 2, LTM_WED }, { "th", 2, LTM_THU }, { "fr", 2, LTM_FRI },
-    { "sa", 2, LTM_SAT }, { "any",3, LTM_ANY }, { "all",3, LTM_ANY }, 
+    { "sa", 2, LTM_SAT }, { "any",3, LTM_ANY }, { "all",3, LTM_ANY },
     { "wk", 2, LTM_WK  }, { "wd", 2, LTM_WD  }, { NULL, 0, 0       }
 };
 
@@ -72,9 +72,10 @@ parse_lt(const char * str)
 	char		buf[64];
 
 	/* Make local copy and force lowercase to simplify parsing */
-	p = strlcpy(buf, str, sizeof buf);
+	strlcpy(buf, str, sizeof buf);
 	for (i = 0; buf[i]; i++)
 	    buf[i] = (char)tolower(buf[i]);
+	p = buf;
 
 	while (isalpha(*p)) {
 
@@ -157,4 +158,3 @@ in_lts(const login_time_t * ltm, time_t 
 {
     return in_ltms(ltm, localtime(t), t);
 }
-
From des at FreeBSD.org  Mon Oct 20 17:07:50 2008
From: des at FreeBSD.org (Dag-Erling Smorgrav)
Date: Mon Oct 20 17:08:03 2008
Subject: svn commit: r184086 - head/lib/libutil
Message-ID: <200810201707.m9KH7onr076100@svn.freebsd.org>

Author: des
Date: Mon Oct 20 17:07:50 2008
New Revision: 184086
URL: http://svn.freebsd.org/changeset/base/184086

Log:
  Style and whitespace

Modified:
  head/lib/libutil/login_times.c

Modified: head/lib/libutil/login_times.c
==============================================================================
--- head/lib/libutil/login_times.c	Mon Oct 20 17:04:57 2008	(r184085)
+++ head/lib/libutil/login_times.c	Mon Oct 20 17:07:50 2008	(r184086)
@@ -34,8 +34,8 @@ __FBSDID("$FreeBSD$");
 static struct
 {
     const char	*dw;
-    u_char      cn;
-    u_char      fl;
+    u_char       cn;
+    u_char       fl;
 } dws[] =
 {
     { "su", 2, LTM_SUN }, { "mo", 2, LTM_MON }, { "tu", 2, LTM_TUE },
@@ -54,22 +54,22 @@ parse_time(char * ptr, u_short * t)
 
     *t = (u_short)((val / 100) * 60 + (val % 100));
 
-    return ptr;
+    return (ptr);
 }
 
 
 login_time_t
-parse_lt(const char * str)
+parse_lt(const char *str)
 {
     login_time_t    t;
 
     memset(&t, 0, sizeof t);
     t.lt_dow = LTM_NONE;
     if (str && *str && strcmp(str, "Never") != 0 && strcmp(str, "None") != 0) {
-	int		i;
-	login_time_t	m = t;
+	int		 i;
+	login_time_t	 m = t;
 	char		*p;
-	char		buf[64];
+	char		 buf[64];
 
 	/* Make local copy and force lowercase to simplify parsing */
 	strlcpy(buf, str, sizeof buf);
@@ -102,12 +102,12 @@ parse_lt(const char * str)
 
 	t = m;
     }
-    return t;
+    return (t);
 }
 
 
 int
-in_ltm(const login_time_t * ltm, struct tm * tt, time_t * ends)
+in_ltm(const login_time_t *ltm, struct tm *tt, time_t *ends)
 {
     int	    rc = 0;
 
@@ -130,31 +130,31 @@ in_ltm(const login_time_t * ltm, struct 
 	    }
 	}
     }
-    return rc;
+    return (rc);
 }
 
 
 int
-in_lt(const login_time_t * ltm, time_t * t)
+in_lt(const login_time_t *ltm, time_t *t)
 {
-    return in_ltm(ltm, localtime(t), t);
+    return (in_ltm(ltm, localtime(t), t));
 }
 
 int
-in_ltms(const login_time_t * ltm, struct tm * tm, time_t * t)
+in_ltms(const login_time_t *ltm, struct tm * tm, time_t *t)
 {
     int	    i = 0;
 
     while (i < LC_MAXTIMES && ltm[i].lt_dow != LTM_NONE) {
 	if (in_ltm(ltm + i, tm, t))
-	    return i;
+	    return (i);
 	i++;
     }
-    return -1;
+    return (-1);
 }
 
 int
-in_lts(const login_time_t * ltm, time_t * t)
+in_lts(const login_time_t *ltm, time_t *t)
 {
-    return in_ltms(ltm, localtime(t), t);
+    return (in_ltms(ltm, localtime(t), t));
 }
From des at FreeBSD.org  Mon Oct 20 17:09:51 2008
From: des at FreeBSD.org (Dag-Erling Smorgrav)
Date: Mon Oct 20 17:09:57 2008
Subject: svn commit: r184087 - head/lib/libutil
Message-ID: <200810201709.m9KH9ow1076171@svn.freebsd.org>

Author: des
Date: Mon Oct 20 17:09:50 2008
New Revision: 184087
URL: http://svn.freebsd.org/changeset/base/184087

Log:
  Additional style and whitespace fixes.

Modified:
  head/lib/libutil/login_times.c

Modified: head/lib/libutil/login_times.c
==============================================================================
--- head/lib/libutil/login_times.c	Mon Oct 20 17:07:50 2008	(r184086)
+++ head/lib/libutil/login_times.c	Mon Oct 20 17:09:50 2008	(r184087)
@@ -137,11 +137,12 @@ in_ltm(const login_time_t *ltm, struct t
 int
 in_lt(const login_time_t *ltm, time_t *t)
 {
+
     return (in_ltm(ltm, localtime(t), t));
 }
 
 int
-in_ltms(const login_time_t *ltm, struct tm * tm, time_t *t)
+in_ltms(const login_time_t *ltm, struct tm *tm, time_t *t)
 {
     int	    i = 0;
 
@@ -156,5 +157,6 @@ in_ltms(const login_time_t *ltm, struct 
 int
 in_lts(const login_time_t *ltm, time_t *t)
 {
+
     return (in_ltms(ltm, localtime(t), t));
 }
From des at FreeBSD.org  Mon Oct 20 17:17:59 2008
From: des at FreeBSD.org (Dag-Erling Smorgrav)
Date: Mon Oct 20 17:18:04 2008
Subject: svn commit: r184088 - head/lib/libutil
Message-ID: <200810201717.m9KHHw4T076352@svn.freebsd.org>

Author: des
Date: Mon Oct 20 17:17:58 2008
New Revision: 184088
URL: http://svn.freebsd.org/changeset/base/184088

Log:
  Since in_lt() and in_lts() are not static, assume that they are intended to
  be part of the public API.  Accordingly, add prototypes and document them.

Modified:
  head/lib/libutil/login_cap.h
  head/lib/libutil/login_times.3

Modified: head/lib/libutil/login_cap.h
==============================================================================
--- head/lib/libutil/login_cap.h	Mon Oct 20 17:09:50 2008	(r184087)
+++ head/lib/libutil/login_cap.h	Mon Oct 20 17:17:58 2008	(r184088)
@@ -146,8 +146,10 @@ int auth_timeok(login_cap_t *, time_t);
 struct tm;
 
 login_time_t parse_lt(const char *);
+int in_lt(const login_time_t *, time_t *);
 int in_ltm(const login_time_t *, struct tm *, time_t *);
 int in_ltms(const login_time_t *, struct tm *, time_t *);
+int in_lts(const login_time_t *, time_t *);
 
 /* helper functions */
 

Modified: head/lib/libutil/login_times.3
==============================================================================
--- head/lib/libutil/login_times.3	Mon Oct 20 17:09:50 2008	(r184087)
+++ head/lib/libutil/login_times.3	Mon Oct 20 17:17:58 2008	(r184088)
@@ -19,13 +19,15 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 2, 1997
+.Dd October 20, 2008
 .Os
 .Dt LOGIN_TIMES 3
 .Sh NAME
 .Nm parse_lt ,
+.Nm in_lt ,
 .Nm in_ltm ,
-.Nm in_ltms
+.Nm in_ltms ,
+.Nm in_lts
 .Nd functions for parsing and checking login time periods
 .Sh LIBRARY
 .Lb libutil
@@ -36,9 +38,13 @@
 .Ft login_time_t
 .Fn parse_lt "const char *str"
 .Ft int
+.Fn in_lt "const login_time_t *lt" "time_t *ends"
+.Ft int
 .Fn in_ltm "const login_time_t *lt" "struct tm *t" "time_t *ends"
 .Ft int
 .Fn in_ltms "const login_time_t *lt" "struct tm *t" "time_t *ends"
+.Ft int
+.Fn in_lts "const login_time_t *lt" "time_t *ends"
 .Sh DESCRIPTION
 This set of functions may be used for parsing and checking login and
 session times against a predefined list of allowed login times as
@@ -135,6 +141,18 @@ elements in length, and terminated by an
 .Ar lt_dow
 field set to
 .Em LTM_NONE .
+.Pp
+The
+.Fn in_lt
+and
+.Fn in_lts
+functions are equivalent to
+.Fn in_ltm
+and
+.Fn in_ltms ,
+respectively, with the second argument set to the current time as
+returned by
+.Xr localtime 3 .
 .Sh RETURN VALUES
 The
 .Fn parse_lt
From mav at FreeBSD.org  Mon Oct 20 17:24:25 2008
From: mav at FreeBSD.org (Alexander Motin)
Date: Mon Oct 20 17:24:31 2008
Subject: svn commit: r184089 - head/sys/dev/sound/pci/hda
Message-ID: <200810201724.m9KHOP8Y076509@svn.freebsd.org>

Author: mav
Date: Mon Oct 20 17:24:25 2008
New Revision: 184089
URL: http://svn.freebsd.org/changeset/base/184089

Log:
  Tune boot messages a bit.
  Use <> brackets only at device name line.

Modified:
  head/sys/dev/sound/pci/hda/hdac.c

Modified: head/sys/dev/sound/pci/hda/hdac.c
==============================================================================
--- head/sys/dev/sound/pci/hda/hdac.c	Mon Oct 20 17:17:58 2008	(r184088)
+++ head/sys/dev/sound/pci/hda/hdac.c	Mon Oct 20 17:24:25 2008	(r184089)
@@ -1854,7 +1854,7 @@ hdac_probe_codec(struct hdac_codec *code
 	nid_t cad = codec->cad;
 
 	HDA_BOOTVERBOSE(
-		device_printf(sc->dev, "Probing codec %d...\n", cad);
+		device_printf(sc->dev, "Probing codec #%d...\n", cad);
 	);
 	vendorid = hdac_command(sc,
 	    HDA_CMD_GET_PARAMETER(cad, 0x0, HDA_PARAM_VENDOR_ID),
@@ -1873,10 +1873,10 @@ hdac_probe_codec(struct hdac_codec *code
 		return;
 	}
 
-	device_printf(sc->dev, "\n",
+	device_printf(sc->dev, "HDA Codec #%d: %s\n",
 	    cad, hdac_codec_name(codec));
 	HDA_BOOTVERBOSE(
-		device_printf(sc->dev, "\n",
+		device_printf(sc->dev, " HDA Codec ID: 0x%08x\n",
 		    hdac_codec_id(codec));
 		device_printf(sc->dev, "       Vendor: 0x%04x\n",
 		    codec->vendor_id);
@@ -3826,7 +3826,7 @@ hdac_attach(device_t dev)
 	uint16_t vendor;
 	uint8_t v;
 
-	device_printf(dev, "\n", HDA_DRV_TEST_REV);
+	device_printf(dev, "HDA Driver Revision: %s\n", HDA_DRV_TEST_REV);
 
 	sc = device_get_softc(dev);
 	sc->lock = snd_mtxcreate(device_get_nameunit(dev), HDAC_MTX_NAME);
From des at FreeBSD.org  Mon Oct 20 17:26:30 2008
From: des at FreeBSD.org (Dag-Erling Smorgrav)
Date: Mon Oct 20 17:26:44 2008
Subject: svn commit: r184090 - head/tools/regression/lib/libutil
Message-ID: <200810201726.m9KHQUgb076589@svn.freebsd.org>

Author: des
Date: Mon Oct 20 17:26:30 2008
New Revision: 184090
URL: http://svn.freebsd.org/changeset/base/184090

Log:
  #ifdef out the lock-against-self test.  I'm not sure it makes sense, and
  it relies on non-portable flock(2) semantics.  Not only is flock(2) not
  portable, but on some OSes that do have it, it is implemented in terms
  of fcntl(2) locks, which are per-process rather than per-descriptor.

Modified:
  head/tools/regression/lib/libutil/test-flopen.c

Modified: head/tools/regression/lib/libutil/test-flopen.c
==============================================================================
--- head/tools/regression/lib/libutil/test-flopen.c	Mon Oct 20 17:24:25 2008	(r184089)
+++ head/tools/regression/lib/libutil/test-flopen.c	Mon Oct 20 17:26:30 2008	(r184090)
@@ -89,6 +89,7 @@ test_flopen_open(void)
 	return (result);
 }
 
+#if FLOPEN_CAN_LOCK_AGAINST_SELF
 /*
  * Test that flopen() can lock against itself
  */
@@ -114,6 +115,7 @@ test_flopen_lock_self(void)
 	unlink(fn);
 	return (result);
 }
+#endif
 
 /*
  * Test that flopen() can lock against other processes
@@ -152,7 +154,9 @@ static struct test {
 } t[] = {
 	{ "flopen_create", test_flopen_create },
 	{ "flopen_open", test_flopen_open },
+#if FLOPEN_CAN_LOCK_AGAINST_SELF
 	{ "flopen_lock_self", test_flopen_lock_self },
+#endif
 	{ "flopen_lock_other", test_flopen_lock_other },
 };
 
From des at FreeBSD.org  Mon Oct 20 17:41:09 2008
From: des at FreeBSD.org (Dag-Erling Smorgrav)
Date: Mon Oct 20 17:41:21 2008
Subject: svn commit: r184091 - head/lib/libutil
Message-ID: <200810201741.m9KHf9G3076906@svn.freebsd.org>

Author: des
Date: Mon Oct 20 17:41:08 2008
New Revision: 184091
URL: http://svn.freebsd.org/changeset/base/184091

Log:
  There is no point in releasing a lock on a file which we've unlinked and
  are about to close, so don't.  As a bonus, pidfile_remove(3) will now
  work with an fcntl(2)-based flopen(3).

Modified:
  head/lib/libutil/pidfile.c

Modified: head/lib/libutil/pidfile.c
==============================================================================
--- head/lib/libutil/pidfile.c	Mon Oct 20 17:26:30 2008	(r184090)
+++ head/lib/libutil/pidfile.c	Mon Oct 20 17:41:08 2008	(r184091)
@@ -231,10 +231,6 @@ _pidfile_remove(struct pidfh *pfh, int f
 
 	if (unlink(pfh->pf_path) == -1)
 		error = errno;
-	if (flock(pfh->pf_fd, LOCK_UN) == -1) {
-		if (error == 0)
-			error = errno;
-	}
 	if (close(pfh->pf_fd) == -1) {
 		if (error == 0)
 			error = errno;
From des at FreeBSD.org  Mon Oct 20 18:00:11 2008
From: des at FreeBSD.org (Dag-Erling Smorgrav)
Date: Mon Oct 20 18:00:23 2008
Subject: svn commit: r184092 - head/lib/libutil
Message-ID: <200810201800.m9KI0BQG077294@svn.freebsd.org>

Author: des
Date: Mon Oct 20 18:00:11 2008
New Revision: 184092
URL: http://svn.freebsd.org/changeset/base/184092

Log:
  pidfile(3) uses flopen(3) - don't make any assumptions about how the
  latter is implemented.

Modified:
  head/lib/libutil/pidfile.3

Modified: head/lib/libutil/pidfile.3
==============================================================================
--- head/lib/libutil/pidfile.3	Mon Oct 20 17:41:08 2008	(r184091)
+++ head/lib/libutil/pidfile.3	Mon Oct 20 18:00:11 2008	(r184092)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 22, 2005
+.Dd October 20, 2008
 .Dt PIDFILE 3
 .Os
 .Sh NAME
@@ -51,16 +51,14 @@ The
 .Nm pidfile
 family of functions allows daemons to handle PID files.
 It uses
-.Xr flock 2
+.Xr flopen 3
 to lock a pidfile and detect already running daemons.
 .Pp
 The
 .Fn pidfile_open
 function opens (or creates) a file specified by the
 .Fa path
-argument and locks it with the
-.Xr flock 2
-system call.
+argument and locks it.
 If a file can not be locked, a PID of an already running daemon is returned in
 the
 .Fa pidptr
@@ -233,16 +231,17 @@ function may also fail and set
 .Va errno
 for any errors specified for the
 .Xr close 2 ,
-.Xr flock 2 ,
 .Xr fstat 2 ,
 .Xr write 2 ,
 and
 .Xr unlink 2
-calls.
+system calls and the
+.Xr flopen 3
+library function.
 .Sh SEE ALSO
-.Xr flock 2 ,
 .Xr open 2 ,
-.Xr daemon 3
+.Xr daemon 3 ,
+.Xr flopen 3
 .Sh AUTHORS
 .An -nosplit
 The
From des at FreeBSD.org  Mon Oct 20 18:02:17 2008
From: des at FreeBSD.org (Dag-Erling Smorgrav)
Date: Mon Oct 20 18:02:31 2008
Subject: svn commit: r184093 - head/lib/libutil
Message-ID: <200810201802.m9KI2GrQ077363@svn.freebsd.org>

Author: des
Date: Mon Oct 20 18:02:16 2008
New Revision: 184093
URL: http://svn.freebsd.org/changeset/base/184093

Log:
  Reimplement flopen(3) using fcntl(2) locks instead of flock(2) locks.

Modified:
  head/lib/libutil/flopen.3
  head/lib/libutil/flopen.c

Modified: head/lib/libutil/flopen.3
==============================================================================
--- head/lib/libutil/flopen.3	Mon Oct 20 18:00:11 2008	(r184092)
+++ head/lib/libutil/flopen.3	Mon Oct 20 18:02:16 2008	(r184093)
@@ -46,12 +46,13 @@ The
 function opens or creates a file and acquires an exclusive lock on it.
 It is essentially equivalent with calling
 .Fn open
-with the same parameters followed by
-.Fn flock
-with an
-.Va operation
-argument of
-.Dv LOCK_EX ,
+with the same parameters followed by an
+.Fn fcntl
+.Dv F_SETLK
+or
+.Dv F_SETLKW
+operation with lock type
+.Dv F_WRLCK ,
 except that
 .Fn flopen
 will attempt to detect and handle races that may occur between opening
@@ -86,12 +87,12 @@ returns a valid file descriptor.
 Otherwise, it returns -1, and sets
 .Va errno
 as described in
-.Xr flock 2
+.Xr fcntl 2
 and
 .Xr open 2 .
 .Sh SEE ALSO
 .Xr errno 2 ,
-.Xr flock 2 ,
+.Xr fcntl 2 ,
 .Xr open 2
 .Sh HISTORY
 The

Modified: head/lib/libutil/flopen.c
==============================================================================
--- head/lib/libutil/flopen.c	Mon Oct 20 18:00:11 2008	(r184092)
+++ head/lib/libutil/flopen.c	Mon Oct 20 18:02:16 2008	(r184093)
@@ -28,12 +28,12 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
 #include 
 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -42,6 +42,7 @@ int
 flopen(const char *path, int flags, ...)
 {
 	int fd, operation, serrno, trunc;
+	struct flock flock;
 	struct stat sb, fsb;
 	mode_t mode;
 
@@ -58,9 +59,10 @@ flopen(const char *path, int flags, ...)
 		va_end(ap);
 	}
 
-	operation = LOCK_EX;
-	if (flags & O_NONBLOCK)
-		operation |= LOCK_NB;
+	memset(&flock, 0, sizeof flock);
+	flock.l_type = F_WRLCK;
+	flock.l_whence = SEEK_SET;
+	operation = (flags & O_NONBLOCK) ? F_SETLK : F_SETLKW;
 
 	trunc = (flags & O_TRUNC);
 	flags &= ~O_TRUNC;
@@ -69,7 +71,7 @@ flopen(const char *path, int flags, ...)
 		if ((fd = open(path, flags, mode)) == -1)
 			/* non-existent or no access */
 			return (-1);
-		if (flock(fd, operation) == -1) {
+		if (fcntl(fd, operation, &flock) == -1) {
 			/* unsupported or interrupted */
 			serrno = errno;
 			close(fd);
From des at FreeBSD.org  Mon Oct 20 18:11:30 2008
From: des at FreeBSD.org (Dag-Erling Smorgrav)
Date: Mon Oct 20 18:11:42 2008
Subject: svn commit: r184094 - head/lib/libutil
Message-ID: <200810201811.m9KIBUdK077567@svn.freebsd.org>

Author: des
Date: Mon Oct 20 18:11:30 2008
New Revision: 184094
URL: http://svn.freebsd.org/changeset/base/184094

Log:
  Diff reduction against Varnish, including one important fix: use a shared
  lock if the file is opened with O_RDONLY.

Modified:
  head/lib/libutil/flopen.c

Modified: head/lib/libutil/flopen.c
==============================================================================
--- head/lib/libutil/flopen.c	Mon Oct 20 18:02:16 2008	(r184093)
+++ head/lib/libutil/flopen.c	Mon Oct 20 18:11:30 2008	(r184094)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2007 Dag-Erling Coïdan Smørgrav
+ * Copyright (c) 2007 Dag-Erling Coïdan Smørgrav
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,7 @@ int
 flopen(const char *path, int flags, ...)
 {
 	int fd, operation, serrno, trunc;
-	struct flock flock;
+	struct flock lock;
 	struct stat sb, fsb;
 	mode_t mode;
 
@@ -55,13 +55,13 @@ flopen(const char *path, int flags, ...)
 		va_list ap;
 
 		va_start(ap, flags);
-		mode = va_arg(ap, int); /* mode_t promoted to int */
+		mode = (mode_t)va_arg(ap, int); /* mode_t promoted to int */
 		va_end(ap);
 	}
 
-	memset(&flock, 0, sizeof flock);
-	flock.l_type = F_WRLCK;
-	flock.l_whence = SEEK_SET;
+	memset(&lock, 0, sizeof lock);
+	lock.l_type = ((flags & O_ACCMODE) == O_RDONLY) ? F_RDLCK : F_WRLCK;
+	lock.l_whence = SEEK_SET;
 	operation = (flags & O_NONBLOCK) ? F_SETLK : F_SETLKW;
 
 	trunc = (flags & O_TRUNC);
@@ -71,35 +71,35 @@ flopen(const char *path, int flags, ...)
 		if ((fd = open(path, flags, mode)) == -1)
 			/* non-existent or no access */
 			return (-1);
-		if (fcntl(fd, operation, &flock) == -1) {
+		if (fcntl(fd, operation, &lock) == -1) {
 			/* unsupported or interrupted */
 			serrno = errno;
-			close(fd);
+			(void)close(fd);
 			errno = serrno;
 			return (-1);
 		}
 		if (stat(path, &sb) == -1) {
 			/* disappeared from under our feet */
-			close(fd);
+			(void)close(fd);
 			continue;
 		}
 		if (fstat(fd, &fsb) == -1) {
 			/* can't happen [tm] */
 			serrno = errno;
-			close(fd);
+			(void)close(fd);
 			errno = serrno;
 			return (-1);
 		}
 		if (sb.st_dev != fsb.st_dev ||
 		    sb.st_ino != fsb.st_ino) {
 			/* changed under our feet */
-			close(fd);
+			(void)close(fd);
 			continue;
 		}
 		if (trunc && ftruncate(fd, 0) != 0) {
 			/* can't happen [tm] */
 			serrno = errno;
-			close(fd);
+			(void)close(fd);
 			errno = serrno;
 			return (-1);
 		}
From delphij at delphij.net  Mon Oct 20 18:23:45 2008
From: delphij at delphij.net (Xin LI)
Date: Mon Oct 20 18:23:50 2008
Subject: svn commit: r183679 - head
In-Reply-To: <86skqrgs0m.fsf@ds4.des.no>
References: <200810080131.m981V0HR016984@svn.freebsd.org>
	<86skqrgs0m.fsf@ds4.des.no>
Message-ID: <48FCCCA4.1000703@delphij.net>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dag-Erling Sm?rgrav wrote:
> Xin LI  writes:
>> Modified: head/UPDATING
>> ==============================================================================
>> --- head/UPDATING	Tue Oct  7 23:55:32 2008	(r183678)
>> +++ head/UPDATING	Wed Oct  8 01:31:00 2008	(r183679)
>> @@ -59,6 +59,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8.
>>  	option to "ssh-dss,ssh-rsa" in ~/.ssh/config or on the ssh
>>  	command line.
>>  
>> +	Please note that the sequence of keys offered for
>> +	authentication has been changed as well.  You may want to
>> +	specify IdentityFile in a different order to revert this
>> +	behavior.
>> +
>>  20080713:
>>  	The sio(4) driver has been removed from the i386 and amd64
>>  	kernel configuration files. This means uart(4) is now the
> 
> You should have asked me before committing this - and you should have
> mentioned and justified the addition it in the commit message.  As it
> is now, the entry gives the impression that this change was an
> unfortunate side effect which needs to be worked around by the user,
> when in fact it was a conscious and deliberate choice intended to
> benefit users.

Sorry for that, I should have double-checked the diff before commit.  Do
you want me to revert this part?

Cheers,
- --
Xin LI 	http://www.delphij.net/
FreeBSD - The Power to Serve!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (FreeBSD)

iEYEARECAAYFAkj8zKQACgkQi+vbBBjt66BxwQCgtxJvkggHpghb48yHfM60MGKe
J7gAn2c8ryI9JKFRneuveHZuF1K6FdVo
=mUYM
-----END PGP SIGNATURE-----
From mav at FreeBSD.org  Mon Oct 20 18:37:11 2008
From: mav at FreeBSD.org (Alexander Motin)
Date: Mon Oct 20 18:37:17 2008
Subject: svn commit: r184095 - head/sys/dev/sound/pci/hda
Message-ID: <200810201837.m9KIbBr7078105@svn.freebsd.org>

Author: mav
Date: Mon Oct 20 18:37:10 2008
New Revision: 184095
URL: http://svn.freebsd.org/changeset/base/184095

Log:
  Make HDA PCM device boot and sndstat messages more alike to PCI device ones.
  Move codec # out of the device name as it is a device address and not part of
  device type name.

Modified:
  head/sys/dev/sound/pci/hda/hdac.c

Modified: head/sys/dev/sound/pci/hda/hdac.c
==============================================================================
--- head/sys/dev/sound/pci/hda/hdac.c	Mon Oct 20 18:11:30 2008	(r184094)
+++ head/sys/dev/sound/pci/hda/hdac.c	Mon Oct 20 18:37:10 2008	(r184095)
@@ -7552,6 +7552,21 @@ hdac_detach(device_t dev)
 	return (0);
 }
 
+static int
+hdac_print_child(device_t dev, device_t child)
+{
+	struct hdac_pcm_devinfo *pdevinfo =
+	    (struct hdac_pcm_devinfo *)device_get_ivars(child);
+	int retval;
+
+	retval = bus_print_child_header(dev, child);
+	retval += printf(" at cad %d nid %d",
+	    pdevinfo->devinfo->codec->cad, pdevinfo->devinfo->nid);
+	retval += bus_print_child_footer(dev, child);
+
+	return (retval);
+}
+
 static device_method_t hdac_methods[] = {
 	/* device interface */
 	DEVMETHOD(device_probe,		hdac_probe),
@@ -7559,6 +7574,8 @@ static device_method_t hdac_methods[] = 
 	DEVMETHOD(device_detach,	hdac_detach),
 	DEVMETHOD(device_suspend,	hdac_suspend),
 	DEVMETHOD(device_resume,	hdac_resume),
+	/* Bus interface */
+	DEVMETHOD(bus_print_child,	hdac_print_child),
 	{ 0, 0 }
 };
 
@@ -7581,8 +7598,7 @@ hdac_pcm_probe(device_t dev)
 	    (struct hdac_pcm_devinfo *)device_get_ivars(dev);
 	char buf[128];
 
-	snprintf(buf, sizeof(buf), "HDA codec #%d %s PCM #%d",
-	    pdevinfo->devinfo->codec->cad,
+	snprintf(buf, sizeof(buf), "HDA %s PCM #%d",
 	    hdac_codec_name(pdevinfo->devinfo->codec),
 	    pdevinfo->index);
 	device_set_desc_copy(dev, buf);
@@ -7673,9 +7689,9 @@ hdac_pcm_attach(device_t dev)
 	if (pdevinfo->rec >= 0)
 		pcm_addchan(dev, PCMDIR_REC, &hdac_channel_class, pdevinfo);
 
-	snprintf(status, SND_STATUSLEN, "at %s cad %d %s [%s]",
-	    device_get_nameunit(sc->dev), pdevinfo->devinfo->codec->cad,
-	    PCM_KLDSTRING(snd_hda), HDA_DRV_TEST_REV);
+	snprintf(status, SND_STATUSLEN, "at cad %d nid %d on %s %s",
+	    pdevinfo->devinfo->codec->cad, pdevinfo->devinfo->nid,
+	    device_get_nameunit(sc->dev), PCM_KLDSTRING(snd_hda));
 	pcm_setstatus(dev, status);
 
 	return (0);
From bz at FreeBSD.org  Mon Oct 20 18:44:00 2008
From: bz at FreeBSD.org (Bjoern A. Zeeb)
Date: Mon Oct 20 18:44:06 2008
Subject: svn commit: r184096 - in head/sys: netinet netinet6
Message-ID: <200810201843.m9KIhxxe078260@svn.freebsd.org>

Author: bz
Date: Mon Oct 20 18:43:59 2008
New Revision: 184096
URL: http://svn.freebsd.org/changeset/base/184096

Log:
  Bring over the change switching from using sequential to random
  ephemeral port allocation as implemented in netinet/in_pcb.c rev. 1.143
  (initially from OpenBSD) and follow-up commits during the last four and
  a half years including rev. 1.157, 1.162 and 1.199.
  This now is relying on the same infrastructure as has been implemented
  in in_pcb.c since rev. 1.199.
  
  Reviewed by:	silby, rpaulo, mlaier
  MFC after:	2 months

Modified:
  head/sys/netinet/in_pcb.h
  head/sys/netinet6/in6_src.c

Modified: head/sys/netinet/in_pcb.h
==============================================================================
--- head/sys/netinet/in_pcb.h	Mon Oct 20 18:37:10 2008	(r184095)
+++ head/sys/netinet/in_pcb.h	Mon Oct 20 18:43:59 2008	(r184096)
@@ -449,6 +449,9 @@ extern int	ipport_firstauto;
 extern int	ipport_lastauto;
 extern int	ipport_hifirstauto;
 extern int	ipport_hilastauto;
+extern int	ipport_randomized;
+extern int	ipport_stoprandom;
+extern int	ipport_tcpallocs;
 extern struct callout ipport_tick_callout;
 
 void	in_pcbpurgeif0(struct inpcbinfo *, struct ifnet *);

Modified: head/sys/netinet6/in6_src.c
==============================================================================
--- head/sys/netinet6/in6_src.c	Mon Oct 20 18:37:10 2008	(r184095)
+++ head/sys/netinet6/in6_src.c	Mon Oct 20 18:43:59 2008	(r184096)
@@ -95,6 +95,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -774,7 +777,7 @@ in6_pcbsetport(struct in6_addr *laddr, s
 	INIT_VNET_INET(curvnet);
 	struct socket *so = inp->inp_socket;
 	u_int16_t lport = 0, first, last, *lastport;
-	int count, error = 0, wild = 0;
+	int count, error = 0, wild = 0, dorandom;
 	struct inpcbinfo *pcbinfo = inp->inp_pcbinfo;
 
 	INP_INFO_WLOCK_ASSERT(pcbinfo);
@@ -802,56 +805,58 @@ in6_pcbsetport(struct in6_addr *laddr, s
 		last  = V_ipport_lastauto;
 		lastport = &pcbinfo->ipi_lastport;
 	}
+
 	/*
-	 * Simple check to ensure all ports are not used up causing
-	 * a deadlock here.
-	 *
-	 * We split the two cases (up and down) so that the direction
-	 * is not being tested on each round of the loop.
+	 * For UDP, use random port allocation as long as the user
+	 * allows it.  For TCP (and as of yet unknown) connections,
+	 * use random port allocation only if the user allows it AND
+	 * ipport_tick() allows it.
 	 */
-	if (first > last) {
-