From owner-svn-src-all@freebsd.org Sun Jul 26 21:37:34 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9F84B99C0B3; Sun, 26 Jul 2015 21:37:34 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7AC4CED; Sun, 26 Jul 2015 21:37:34 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6QLbYCC084095; Sun, 26 Jul 2015 21:37:34 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6QLbWrw084088; Sun, 26 Jul 2015 21:37:32 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201507262137.t6QLbWrw084088@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Sun, 26 Jul 2015 21:37:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285903 - in head/tools/bus_space: . C Python X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Jul 2015 21:37:34 -0000 Author: marcel Date: Sun Jul 26 21:37:31 2015 New Revision: 285903 URL: https://svnweb.freebsd.org/changeset/base/285903 Log: Change the dev argument from a full path to just the device identification (e.g. isa:0x3f0 or pci0:2:1:0). In libbus, the device is turned into a path name. For bus_space_map(), the resource is now specified in a second argument. Before: bus.map('/dev/proto/pci0:2:1:0/pcicfg') busdma.tag_create('/dev/proto/pci0:2:1:0/busdma', ...) Now: bus.map('pci0:2:1:0', 'pcicfg') busdma.tag_create('pci0:2:1:0', ...) Modified: head/tools/bus_space/C/lang.c head/tools/bus_space/C/libbus.h head/tools/bus_space/Python/lang.c head/tools/bus_space/bus.c head/tools/bus_space/bus.h head/tools/bus_space/busdma.c Modified: head/tools/bus_space/C/lang.c ============================================================================== --- head/tools/bus_space/C/lang.c Sun Jul 26 19:47:46 2015 (r285902) +++ head/tools/bus_space/C/lang.c Sun Jul 26 21:37:31 2015 (r285903) @@ -80,10 +80,10 @@ bus_write_4(int rid, long ofs, uint32_t } int -bus_map(const char *dev) +bus_map(const char *dev, const char *resource) { - return (bs_map(dev)); + return (bs_map(dev, resource)); } int Modified: head/tools/bus_space/C/libbus.h ============================================================================== --- head/tools/bus_space/C/libbus.h Sun Jul 26 19:47:46 2015 (r285902) +++ head/tools/bus_space/C/libbus.h Sun Jul 26 21:37:31 2015 (r285903) @@ -29,7 +29,7 @@ #ifndef _LIBBUS_SPACE_H_ #define _LIBBUS_SPACE_H_ -int bus_map(const char *dev); +int bus_map(const char *dev, const char *resource); int16_t bus_read_1(int rid, long ofs); int32_t bus_read_2(int rid, long ofs); int64_t bus_read_4(int rid, long ofs); Modified: head/tools/bus_space/Python/lang.c ============================================================================== --- head/tools/bus_space/Python/lang.c Sun Jul 26 19:47:46 2015 (r285902) +++ head/tools/bus_space/Python/lang.c Sun Jul 26 21:37:31 2015 (r285903) @@ -131,12 +131,12 @@ bus_write_4(PyObject *self, PyObject *ar static PyObject * bus_map(PyObject *self, PyObject *args) { - char *dev; + char *dev, *resource; int rid; - if (!PyArg_ParseTuple(args, "s", &dev)) + if (!PyArg_ParseTuple(args, "ss", &dev, &resource)) return (NULL); - rid = bs_map(dev); + rid = bs_map(dev, resource); if (rid == -1) { PyErr_SetString(PyExc_IOError, strerror(errno)); return (NULL); Modified: head/tools/bus_space/bus.c ============================================================================== --- head/tools/bus_space/bus.c Sun Jul 26 19:47:46 2015 (r285902) +++ head/tools/bus_space/bus.c Sun Jul 26 21:37:31 2015 (r285903) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -92,19 +93,25 @@ rid_lookup(int rid) } int -bs_map(const char *dev) +bs_map(const char *dev, const char *res) { + char path[PATH_MAX]; struct proto_ioc_region region; struct resource *r; - int rid; + int len, rid; + len = snprintf(path, PATH_MAX, "/dev/proto/%s/%s", dev, res); + if (len >= PATH_MAX) { + errno = EINVAL; + return (-1); + } rid = rid_alloc(); if (rid == -1) return (-1); r = rid_lookup(rid); if (r == NULL) return (-1); - r->fd = open(dev, O_RDWR); + r->fd = open(path, O_RDWR); if (r->fd == -1) return (-1); r->rid = -1; Modified: head/tools/bus_space/bus.h ============================================================================== --- head/tools/bus_space/bus.h Sun Jul 26 19:47:46 2015 (r285902) +++ head/tools/bus_space/bus.h Sun Jul 26 21:37:31 2015 (r285903) @@ -29,7 +29,7 @@ #ifndef _TOOLS_BUS_SPACE_H_ #define _TOOLS_BUS_SPACE_H_ -int bs_map(const char *dev); +int bs_map(const char *dev, const char *res); int bs_read(int rid, off_t ofs, void *buf, ssize_t bufsz); int bs_subregion(int rid0, long ofs, long sz); int bs_unmap(int rid); Modified: head/tools/bus_space/busdma.c ============================================================================== --- head/tools/bus_space/busdma.c Sun Jul 26 19:47:46 2015 (r285902) +++ head/tools/bus_space/busdma.c Sun Jul 26 21:37:31 2015 (r285903) @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -183,10 +184,16 @@ int bd_tag_create(const char *dev, u_long align, u_long bndry, u_long maxaddr, u_long maxsz, u_int nsegs, u_long maxsegsz, u_int datarate, u_int flags) { + char path[PATH_MAX]; struct obj *tag; - int fd; + int fd, len; - fd = open(dev, O_RDWR); + len = snprintf(path, PATH_MAX, "/dev/proto/%s/busdma", dev); + if (len >= PATH_MAX) { + errno = EINVAL; + return (-1); + } + fd = open(path, O_RDWR); if (fd == -1) return (-1);