svn commit: r260916 - in projects/sendfile: include lib/libc/gen libexec/getty sys/dev/uart sys/ia64/ia64 sys/vm sys/x86/x86 usr.sbin/pciconf
Gleb Smirnoff
glebius at FreeBSD.org
Mon Jan 20 18:51:18 UTC 2014
Author: glebius
Date: Mon Jan 20 18:51:16 2014
New Revision: 260916
URL: http://svnweb.freebsd.org/changeset/base/260916
Log:
Merge head up to r260915.
Modified:
projects/sendfile/include/ttyent.h
projects/sendfile/lib/libc/gen/getttyent.c
projects/sendfile/libexec/getty/ttys.5
projects/sendfile/sys/dev/uart/uart_core.c
projects/sendfile/sys/ia64/ia64/pmap.c
projects/sendfile/sys/vm/vnode_pager.c
projects/sendfile/sys/x86/x86/nexus.c
projects/sendfile/usr.sbin/pciconf/pciconf.8
projects/sendfile/usr.sbin/pciconf/pciconf.c
Directory Properties:
projects/sendfile/ (props changed)
projects/sendfile/include/ (props changed)
projects/sendfile/lib/libc/ (props changed)
projects/sendfile/sys/ (props changed)
Modified: projects/sendfile/include/ttyent.h
==============================================================================
--- projects/sendfile/include/ttyent.h Mon Jan 20 18:47:56 2014 (r260915)
+++ projects/sendfile/include/ttyent.h Mon Jan 20 18:51:16 2014 (r260916)
@@ -37,6 +37,7 @@
#define _TTYS_OFF "off"
#define _TTYS_ON "on"
+#define _TTYS_ONIFCONSOLE "onifconsole"
#define _TTYS_SECURE "secure"
#define _TTYS_INSECURE "insecure"
#define _TTYS_WINDOW "window"
Modified: projects/sendfile/lib/libc/gen/getttyent.c
==============================================================================
--- projects/sendfile/lib/libc/gen/getttyent.c Mon Jan 20 18:47:56 2014 (r260915)
+++ projects/sendfile/lib/libc/gen/getttyent.c Mon Jan 20 18:51:16 2014 (r260916)
@@ -39,6 +39,9 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <string.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
static char zapchar;
static FILE *tf;
static size_t lbsize;
@@ -64,6 +67,36 @@ getttynam(const char *tty)
return (t);
}
+static int
+auto_tty_status(const char *ty_name)
+{
+ size_t len;
+ char *buf, *cons, *nextcons;
+
+ /* Check if this is an enabled kernel console line */
+ buf = NULL;
+ if (sysctlbyname("kern.console", NULL, &len, NULL, 0) == -1)
+ return (0); /* Errors mean don't enable */
+ buf = malloc(len);
+ if (sysctlbyname("kern.console", buf, &len, NULL, 0) == -1)
+ goto done;
+
+ if ((cons = strchr(buf, '/')) == NULL)
+ goto done;
+ *cons = '\0';
+ nextcons = buf;
+ while ((cons = strsep(&nextcons, ",")) != NULL && strlen(cons) != 0) {
+ if (strcmp(cons, ty_name) == 0) {
+ free(buf);
+ return (TTY_ON);
+ }
+ }
+
+done:
+ free(buf);
+ return (0);
+}
+
struct ttyent *
getttyent(void)
{
@@ -126,6 +159,8 @@ getttyent(void)
tty.ty_status &= ~TTY_ON;
else if (scmp(_TTYS_ON))
tty.ty_status |= TTY_ON;
+ else if (scmp(_TTYS_ONIFCONSOLE))
+ tty.ty_status |= auto_tty_status(tty.ty_name);
else if (scmp(_TTYS_SECURE))
tty.ty_status |= TTY_SECURE;
else if (scmp(_TTYS_INSECURE))
Modified: projects/sendfile/libexec/getty/ttys.5
==============================================================================
--- projects/sendfile/libexec/getty/ttys.5 Mon Jan 20 18:47:56 2014 (r260915)
+++ projects/sendfile/libexec/getty/ttys.5 Mon Jan 20 18:51:16 2014 (r260916)
@@ -102,8 +102,11 @@ ttys as a group.
.Pp
As flag values, the strings ``on'' and ``off'' specify that
.Xr init 8
-should (should not) execute the command given in the second field,
-while ``secure'' (if ``on'' is also specified) allows users with a
+should (should not) execute the command given in the second field.
+``onifconsole'' will cause this line to be enabled if and only if it is
+an active kernel console device (it is equivalent to ``on'' in this
+case).
+The flag ``secure'' (if the console is enabled) allows users with a
uid of 0 to login on
this line.
The flag ``dialin'' indicates that a tty entry describes a dialin
Modified: projects/sendfile/sys/dev/uart/uart_core.c
==============================================================================
--- projects/sendfile/sys/dev/uart/uart_core.c Mon Jan 20 18:47:56 2014 (r260915)
+++ projects/sendfile/sys/dev/uart/uart_core.c Mon Jan 20 18:51:16 2014 (r260916)
@@ -629,18 +629,14 @@ void
uart_grab(struct uart_devinfo *di)
{
- uart_lock(di->hwmtx);
if (di->sc)
UART_GRAB(di->sc);
- uart_unlock(di->hwmtx);
}
void
uart_ungrab(struct uart_devinfo *di)
{
- uart_lock(di->hwmtx);
if (di->sc)
UART_UNGRAB(di->sc);
- uart_unlock(di->hwmtx);
}
Modified: projects/sendfile/sys/ia64/ia64/pmap.c
==============================================================================
--- projects/sendfile/sys/ia64/ia64/pmap.c Mon Jan 20 18:47:56 2014 (r260915)
+++ projects/sendfile/sys/ia64/ia64/pmap.c Mon Jan 20 18:51:16 2014 (r260916)
@@ -1303,6 +1303,8 @@ pmap_set_pte(struct ia64_lpte *pte, vm_o
pte->itir = PAGE_SHIFT << 2;
+ ia64_mf();
+
pte->tag = ia64_ttag(va);
}
@@ -1321,8 +1323,8 @@ pmap_remove_pte(pmap_t pmap, struct ia64
* First remove from the VHPT.
*/
error = pmap_remove_vhpt(va);
- if (error)
- return (error);
+ KASSERT(error == 0, ("%s: pmap_remove_vhpt returned %d",
+ __func__, error));
pmap_invalidate_page(va);
Modified: projects/sendfile/sys/vm/vnode_pager.c
==============================================================================
--- projects/sendfile/sys/vm/vnode_pager.c Mon Jan 20 18:47:56 2014 (r260915)
+++ projects/sendfile/sys/vm/vnode_pager.c Mon Jan 20 18:51:16 2014 (r260916)
@@ -244,8 +244,7 @@ retry:
* The object must be locked.
*/
static void
-vnode_pager_dealloc(object)
- vm_object_t object;
+vnode_pager_dealloc(vm_object_t object)
{
struct vnode *vp;
int refs;
@@ -280,11 +279,8 @@ vnode_pager_dealloc(object)
}
static boolean_t
-vnode_pager_haspage(object, pindex, before, after)
- vm_object_t object;
- vm_pindex_t pindex;
- int *before;
- int *after;
+vnode_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *before,
+ int *after)
{
struct vnode *vp = object->handle;
daddr_t bn;
@@ -363,9 +359,7 @@ vnode_pager_haspage(object, pindex, befo
* operation (possibly at object termination time), so we must be careful.
*/
void
-vnode_pager_setsize(vp, nsize)
- struct vnode *vp;
- vm_ooffset_t nsize;
+vnode_pager_setsize(struct vnode *vp, vm_ooffset_t nsize)
{
vm_object_t object;
vm_page_t m;
@@ -490,9 +484,7 @@ vnode_pager_addr(struct vnode *vp, vm_oo
* small block filesystem vnode pager input
*/
static int
-vnode_pager_input_smlfs(object, m)
- vm_object_t object;
- vm_page_t m;
+vnode_pager_input_smlfs(vm_object_t object, vm_page_t m)
{
struct vnode *vp;
struct bufobj *bo;
@@ -584,9 +576,7 @@ vnode_pager_input_smlfs(object, m)
* old style vnode pager input routine
*/
static int
-vnode_pager_input_old(object, m)
- vm_object_t object;
- vm_page_t m;
+vnode_pager_input_old(vm_object_t object, vm_page_t m)
{
struct uio auio;
struct iovec aiov;
@@ -659,11 +649,7 @@ vnode_pager_input_old(object, m)
* backing vp's VOP_GETPAGES.
*/
static int
-vnode_pager_getpages(object, m, count, reqpage)
- vm_object_t object;
- vm_page_t *m;
- int count;
- int reqpage;
+vnode_pager_getpages(vm_object_t object, vm_page_t *m, int count, int reqpage)
{
int rtval;
struct vnode *vp;
@@ -683,11 +669,8 @@ vnode_pager_getpages(object, m, count, r
* own vnodes if they fail to implement VOP_GETPAGES.
*/
int
-vnode_pager_generic_getpages(vp, m, bytecount, reqpage)
- struct vnode *vp;
- vm_page_t *m;
- int bytecount;
- int reqpage;
+vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m, int bytecount,
+ int reqpage)
{
vm_object_t object;
vm_offset_t kva;
@@ -1024,12 +1007,8 @@ vnode_pager_generic_getpages(vp, m, byte
* backing vp's VOP_PUTPAGES.
*/
static void
-vnode_pager_putpages(object, m, count, sync, rtvals)
- vm_object_t object;
- vm_page_t *m;
- int count;
- boolean_t sync;
- int *rtvals;
+vnode_pager_putpages(vm_object_t object, vm_page_t *m, int count,
+ boolean_t sync, int *rtvals)
{
int rtval;
struct vnode *vp;
Modified: projects/sendfile/sys/x86/x86/nexus.c
==============================================================================
--- projects/sendfile/sys/x86/x86/nexus.c Mon Jan 20 18:47:56 2014 (r260915)
+++ projects/sendfile/sys/x86/x86/nexus.c Mon Jan 20 18:51:16 2014 (r260916)
@@ -368,12 +368,13 @@ nexus_alloc_resource(device_t bus, devic
int needactivate = flags & RF_ACTIVE;
/*
- * If this is an allocation of the "default" range for a given RID, and
- * we know what the resources for this device are (ie. they aren't maintained
- * by a child bus), then work out the start/end values.
+ * If this is an allocation of the "default" range for a given
+ * RID, and we know what the resources for this device are
+ * (ie. they aren't maintained by a child bus), then work out
+ * the start/end values.
*/
if ((start == 0UL) && (end == ~0UL) && (count == 1)) {
- if (ndev == NULL)
+ if (device_get_parent(child) != bus || ndev == NULL)
return(NULL);
rle = resource_list_find(&ndev->nx_resources, type, *rid);
if (rle == NULL)
@@ -492,6 +493,7 @@ static int
nexus_release_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
+
if (rman_get_flags(r) & RF_ACTIVE) {
int error = bus_deactivate_resource(child, type, rid, r);
if (error)
Modified: projects/sendfile/usr.sbin/pciconf/pciconf.8
==============================================================================
--- projects/sendfile/usr.sbin/pciconf/pciconf.8 Mon Jan 20 18:47:56 2014 (r260915)
+++ projects/sendfile/usr.sbin/pciconf/pciconf.8 Mon Jan 20 18:51:16 2014 (r260916)
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 1, 2012
+.Dd January 20, 2014
.Dt PCICONF 8
.Os
.Sh NAME
@@ -33,13 +33,13 @@
.Nd diagnostic utility for the PCI bus
.Sh SYNOPSIS
.Nm
-.Fl l Op Fl bcev
+.Fl l Oo Fl bcev Oc Op Ar device
.Nm
-.Fl a Ar selector
+.Fl a Ar device
.Nm
-.Fl r Oo Fl b | h Oc Ar selector addr Ns Op : Ns Ar addr2
+.Fl r Oo Fl b | h Oc Ar device addr Ns Op : Ns Ar addr2
.Nm
-.Fl w Oo Fl b | h Oc Ar selector addr value
+.Fl w Oo Fl b | h Oc Ar device addr value
.Sh DESCRIPTION
The
.Nm
@@ -54,7 +54,9 @@ normally only the super-user.
.Pp
With the
.Fl l
-option, it lists all devices found by the boot probe in the following format:
+option,
+.Nm
+lists PCI devices in the following format:
.Bd -literal
foo0 at pci0:0:4:0: class=0x010000 card=0x00000000 chip=0x000f1000 rev=0x01 \
hdr=0x00
@@ -65,16 +67,14 @@ hdr=0x00
.Ed
.Pp
The first column gives the
-device name, unit number, and
-.Ar selector .
-If there is no device configured in the kernel for the
+driver name, unit number, and selector .
+If there is no driver attached to the
.Tn PCI
-device in question, the device name will be
+device in question, the driver name will be
.Dq none .
-Unit numbers for unconfigured devices start at zero and are incremented for
-each unconfigured device that is encountered.
-The
-.Ar selector
+Unit numbers for detached devices start at zero and are incremented for
+each detached device that is encountered.
+The selector
is in a form which may directly be used for the other forms of the command.
The second column is the class code, with the class byte printed as two
hex digits, followed by the sub-class and the interface bytes.
@@ -182,18 +182,36 @@ option is supplied,
will attempt to load the vendor/device information database, and print
vendor, device, class and subclass identification strings for each device.
.Pp
+If the optional
+.Ar device
+argument is given with the
+.Fl l
+flag,
+.Nm
+will only list details about a single device instead of all devices.
+.Pp
All invocations of
.Nm
except for
.Fl l
require a
-.Ar selector
-of the form
+.Ar device .
+The device can be identified either by a device name if the device is
+attached to a driver or by a selector.
+Selectors identify a PCI device by its address in PCI config space and
+can take one of the following forms:
+.Pp
+.Bl -bullet -offset indent -compact
+.It
.Li pci Ns Va domain Ns \&: Ns Va bus Ns \&: Ns Va device Ns \&: \
-Ns Va function Ns ,
-.Li pci Ns Va bus Ns \&: Ns Va device Ns \&: Ns Va function Ns , or
-.Li pci Ns Va bus Ns \&: Ns Va device Ns .
-In case of an abridged form, omitted selector components are assumed to be 0.
+Ns Va function Ns
+.It
+.Li pci Ns Va bus Ns \&: Ns Va device Ns \&: Ns Va function Ns
+.It
+.Li pci Ns Va bus Ns \&: Ns Va device Ns
+.El
+.Pp
+In the case of an abridged form, omitted selector components are assumed to be 0.
An optional leading device name followed by @ and an optional final colon
will be ignored; this is so that the first column in the output of
.Nm
Modified: projects/sendfile/usr.sbin/pciconf/pciconf.c
==============================================================================
--- projects/sendfile/usr.sbin/pciconf/pciconf.c Mon Jan 20 18:47:56 2014 (r260915)
+++ projects/sendfile/usr.sbin/pciconf/pciconf.c Mon Jan 20 18:51:16 2014 (r260916)
@@ -35,6 +35,7 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/fcntl.h>
+#include <assert.h>
#include <ctype.h>
#include <err.h>
#include <inttypes.h>
@@ -67,8 +68,10 @@ struct pci_vendor_info
TAILQ_HEAD(,pci_vendor_info) pci_vendors;
+static struct pcisel getsel(const char *str);
static void list_bars(int fd, struct pci_conf *p);
-static void list_devs(int verbose, int bars, int caps, int errors);
+static void list_devs(const char *name, int verbose, int bars, int caps,
+ int errors);
static void list_verbose(struct pci_conf *p);
static const char *guess_class(struct pci_conf *p);
static const char *guess_subclass(struct pci_conf *p);
@@ -83,10 +86,10 @@ static void
usage(void)
{
fprintf(stderr, "%s\n%s\n%s\n%s\n",
- "usage: pciconf -l [-bcev]",
- " pciconf -a selector",
- " pciconf -r [-b | -h] selector addr[:addr2]",
- " pciconf -w [-b | -h] selector addr value");
+ "usage: pciconf -l [-bcev] [device]",
+ " pciconf -a device",
+ " pciconf -r [-b | -h] device addr[:addr2]",
+ " pciconf -w [-b | -h] device addr value");
exit (1);
}
@@ -145,14 +148,15 @@ main(int argc, char **argv)
}
}
- if ((listmode && optind != argc)
+ if ((listmode && optind >= argc + 1)
|| (writemode && optind + 3 != argc)
|| (readmode && optind + 2 != argc)
|| (attachedmode && optind + 1 != argc))
usage();
if (listmode) {
- list_devs(verbose, bars, caps, errors);
+ list_devs(optind + 1 == argc ? argv[optind] : NULL, verbose,
+ bars, caps, errors);
} else if (attachedmode) {
chkattached(argv[optind]);
} else if (readmode) {
@@ -169,11 +173,12 @@ main(int argc, char **argv)
}
static void
-list_devs(int verbose, int bars, int caps, int errors)
+list_devs(const char *name, int verbose, int bars, int caps, int errors)
{
int fd;
struct pci_conf_io pc;
struct pci_conf conf[255], *p;
+ struct pci_match_conf patterns[1];
int none_count = 0;
if (verbose)
@@ -186,6 +191,16 @@ list_devs(int verbose, int bars, int cap
bzero(&pc, sizeof(struct pci_conf_io));
pc.match_buf_len = sizeof(conf);
pc.matches = conf;
+ if (name != NULL) {
+ bzero(&patterns, sizeof(patterns));
+ patterns[0].pc_sel = getsel(name);
+ patterns[0].flags = PCI_GETCONF_MATCH_DOMAIN |
+ PCI_GETCONF_MATCH_BUS | PCI_GETCONF_MATCH_DEV |
+ PCI_GETCONF_MATCH_FUNC;
+ pc.num_patterns = 1;
+ pc.pat_buf_len = sizeof(patterns);
+ pc.patterns = patterns;
+ }
do {
if (ioctl(fd, PCIOCGETCONF, &pc) == -1)
@@ -557,7 +572,61 @@ read_config(int fd, struct pcisel *sel,
}
static struct pcisel
-getsel(const char *str)
+getdevice(const char *name)
+{
+ struct pci_conf_io pc;
+ struct pci_conf conf[1];
+ struct pci_match_conf patterns[1];
+ char *cp;
+ int fd;
+
+ fd = open(_PATH_DEVPCI, O_RDONLY, 0);
+ if (fd < 0)
+ err(1, "%s", _PATH_DEVPCI);
+
+ bzero(&pc, sizeof(struct pci_conf_io));
+ pc.match_buf_len = sizeof(conf);
+ pc.matches = conf;
+
+ bzero(&patterns, sizeof(patterns));
+
+ /*
+ * The pattern structure requires the unit to be split out from
+ * the driver name. Walk backwards from the end of the name to
+ * find the start of the unit.
+ */
+ if (name[0] == '\0')
+ err(1, "Empty device name");
+ cp = strchr(name, '\0');
+ assert(cp != NULL && cp != name);
+ cp--;
+ while (cp != name && isdigit(cp[-1]))
+ cp--;
+ if (cp == name)
+ errx(1, "Invalid device name");
+ if ((size_t)(cp - name) + 1 > sizeof(patterns[0].pd_name))
+ errx(1, "Device name i2s too long");
+ memcpy(patterns[0].pd_name, name, cp - name);
+ patterns[0].pd_unit = strtol(cp, &cp, 10);
+ assert(*cp == '\0');
+ patterns[0].flags = PCI_GETCONF_MATCH_NAME | PCI_GETCONF_MATCH_UNIT;
+ pc.num_patterns = 1;
+ pc.pat_buf_len = sizeof(patterns);
+ pc.patterns = patterns;
+
+ if (ioctl(fd, PCIOCGETCONF, &pc) == -1)
+ err(1, "ioctl(PCIOCGETCONF)");
+ if (pc.status != PCI_GETCONF_LAST_DEVICE &&
+ pc.status != PCI_GETCONF_MORE_DEVS)
+ errx(1, "error returned from PCIOCGETCONF ioctl");
+ close(fd);
+ if (pc.num_matches == 0)
+ errx(1, "Device not found");
+ return (conf[0].pc_sel);
+}
+
+static struct pcisel
+parsesel(const char *str)
{
char *ep = strchr(str, '@');
char *epbase;
@@ -595,6 +664,20 @@ getsel(const char *str)
return sel;
}
+static struct pcisel
+getsel(const char *str)
+{
+
+ /*
+ * No device names contain colons and selectors always contain
+ * at least one colon.
+ */
+ if (strchr(str, ':') == NULL)
+ return (getdevice(str));
+ else
+ return (parsesel(str));
+}
+
static void
readone(int fd, struct pcisel *sel, long reg, int width)
{
More information about the svn-src-projects
mailing list