summaryrefslogtreecommitdiffstats
path: root/tools/bus_space
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2015-07-26 21:37:31 +0000
committermarcel <marcel@FreeBSD.org>2015-07-26 21:37:31 +0000
commita1823ab55e152ac47502eec09cf01b23ef1e9bb3 (patch)
tree59ac184600735945ed7377cd16ed2f73e6490328 /tools/bus_space
parenteb9cf93f912e1018f8d81e7512e11b4d97b78c95 (diff)
downloadFreeBSD-src-a1823ab55e152ac47502eec09cf01b23ef1e9bb3.zip
FreeBSD-src-a1823ab55e152ac47502eec09cf01b23ef1e9bb3.tar.gz
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', ...)
Diffstat (limited to 'tools/bus_space')
-rw-r--r--tools/bus_space/C/lang.c4
-rw-r--r--tools/bus_space/C/libbus.h2
-rw-r--r--tools/bus_space/Python/lang.c6
-rw-r--r--tools/bus_space/bus.c13
-rw-r--r--tools/bus_space/bus.h2
-rw-r--r--tools/bus_space/busdma.c11
6 files changed, 26 insertions, 12 deletions
diff --git a/tools/bus_space/C/lang.c b/tools/bus_space/C/lang.c
index d9c3f52..f9b404b 100644
--- a/tools/bus_space/C/lang.c
+++ b/tools/bus_space/C/lang.c
@@ -80,10 +80,10 @@ bus_write_4(int rid, long ofs, uint32_t val)
}
int
-bus_map(const char *dev)
+bus_map(const char *dev, const char *resource)
{
- return (bs_map(dev));
+ return (bs_map(dev, resource));
}
int
diff --git a/tools/bus_space/C/libbus.h b/tools/bus_space/C/libbus.h
index 50efd38..0fae987 100644
--- a/tools/bus_space/C/libbus.h
+++ b/tools/bus_space/C/libbus.h
@@ -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);
diff --git a/tools/bus_space/Python/lang.c b/tools/bus_space/Python/lang.c
index 0b96db3..48a112b 100644
--- a/tools/bus_space/Python/lang.c
+++ b/tools/bus_space/Python/lang.c
@@ -131,12 +131,12 @@ bus_write_4(PyObject *self, PyObject *args)
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);
diff --git a/tools/bus_space/bus.c b/tools/bus_space/bus.c
index 01b7693..1b0d2ca 100644
--- a/tools/bus_space/bus.c
+++ b/tools/bus_space/bus.c
@@ -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;
diff --git a/tools/bus_space/bus.h b/tools/bus_space/bus.h
index d347106..a1835d7 100644
--- a/tools/bus_space/bus.h
+++ b/tools/bus_space/bus.h
@@ -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);
diff --git a/tools/bus_space/busdma.c b/tools/bus_space/busdma.c
index d50d5d2..3f948b7 100644
--- a/tools/bus_space/busdma.c
+++ b/tools/bus_space/busdma.c
@@ -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);
OpenPOWER on IntegriCloud