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', ...)
This commit is contained in:
parent
eb9cf93f91
commit
a1823ab55e
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user