Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Jul 2015 21:37:32 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
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
Message-ID:  <201507262137.t6QLbWrw084088@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <errno.h>
 #include <fcntl.h>
 #include <limits.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 
@@ -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 <errno.h>
 #include <fcntl.h>
 #include <limits.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -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);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507262137.t6QLbWrw084088>