Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F174646453
D58106.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D58106.id.diff
View Options
diff --git a/sys/dev/ofw/ofw_pcib.c b/sys/dev/ofw/ofw_pcib.c
--- a/sys/dev/ofw/ofw_pcib.c
+++ b/sys/dev/ofw/ofw_pcib.c
@@ -97,6 +97,7 @@
* local methods
*/
static int ofw_pcib_fill_ranges(phandle_t, struct ofw_pci_range *);
+static int ofw_pcib_fill_dma_ranges(phandle_t, struct ofw_pci_range *);
/*
* Driver methods.
@@ -191,7 +192,7 @@
} else {
sc->sc_nrange = ofw_pcib_nranges(node, cell_info);
if (sc->sc_nrange <= 0) {
- device_printf(dev, "could not getranges\n");
+ device_printf(dev, "could not get ranges\n");
error = ENXIO;
goto out;
}
@@ -200,6 +201,18 @@
ofw_pcib_fill_ranges(node, sc->sc_range);
}
+ if (OF_hasprop(node, "dma-ranges")) {
+ sc->sc_dma_nrange = ofw_pcib_dma_nranges(node, cell_info);
+ if (sc->sc_dma_nrange <= 0) {
+ device_printf(dev, "could not get dma-ranges\n");
+ error = ENXIO;
+ goto out;
+ }
+ sc->sc_dma_range = malloc(sc->sc_dma_nrange *
+ sizeof(sc->sc_dma_range[0]), M_DEVBUF, M_WAITOK);
+ ofw_pcib_fill_dma_ranges(node, sc->sc_dma_range);
+ }
+
sc->sc_io_rman.rm_type = RMAN_ARRAY;
sc->sc_io_rman.rm_descr = "PCI I/O Ports";
error = rman_init(&sc->sc_io_rman);
@@ -390,34 +403,6 @@
return (ENOENT);
}
-int
-ofw_pcib_nranges(phandle_t node, struct ofw_pci_cell_info *info)
-{
- ssize_t nbase_ranges;
-
- if (info == NULL)
- return (-1);
-
- info->host_address_cells = 1;
- info->size_cells = 2;
- info->pci_address_cell = 3;
-
- OF_getencprop(OF_parent(node), "#address-cells",
- &(info->host_address_cells), sizeof(info->host_address_cells));
- OF_getencprop(node, "#address-cells",
- &(info->pci_address_cell), sizeof(info->pci_address_cell));
- OF_getencprop(node, "#size-cells", &(info->size_cells),
- sizeof(info->size_cells));
-
- nbase_ranges = OF_getproplen(node, "ranges");
- if (nbase_ranges <= 0)
- return (-1);
-
- return (nbase_ranges / sizeof(cell_t) /
- (info->pci_address_cell + info->host_address_cells +
- info->size_cells));
-}
-
static struct resource *
ofw_pcib_alloc_resource(device_t bus, device_t child, int type, int rid,
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
@@ -658,7 +643,38 @@
}
static int
-ofw_pcib_fill_ranges(phandle_t node, struct ofw_pci_range *ranges)
+ofw_pcib_nranges_impl(char *prop_name, phandle_t node,
+ struct ofw_pci_cell_info *info)
+{
+ ssize_t nbase_ranges;
+
+ if (info == NULL)
+ return (-1);
+
+ info->host_address_cells = 1;
+ info->size_cells = 2;
+ info->pci_address_cell = 3;
+
+ OF_getencprop(OF_parent(node), "#address-cells",
+ &(info->host_address_cells), sizeof(info->host_address_cells));
+ OF_getencprop(node, "#address-cells",
+ &(info->pci_address_cell), sizeof(info->pci_address_cell));
+ OF_getencprop(node, "#size-cells", &(info->size_cells),
+ sizeof(info->size_cells));
+
+ nbase_ranges = OF_getproplen(node, prop_name);
+ if (nbase_ranges < 0)
+ return (-1);
+
+ return (nbase_ranges / sizeof(cell_t) /
+ (info->pci_address_cell + info->host_address_cells +
+ info->size_cells));
+}
+
+
+static int
+ofw_pcib_fill_ranges_impl(char *prop_name, phandle_t node,
+ struct ofw_pci_range *ranges)
{
int host_address_cells = 1, pci_address_cells = 3, size_cells = 2;
cell_t *base_ranges;
@@ -672,14 +688,14 @@
sizeof(pci_address_cells));
OF_getencprop(node, "#size-cells", &size_cells, sizeof(size_cells));
- nbase_ranges = OF_getproplen(node, "ranges");
- if (nbase_ranges <= 0)
+ nbase_ranges = OF_getproplen(node, prop_name);
+ if (nbase_ranges < 0)
return (-1);
nranges = nbase_ranges / sizeof(cell_t) /
(pci_address_cells + host_address_cells + size_cells);
base_ranges = malloc(nbase_ranges, M_DEVBUF, M_WAITOK);
- OF_getencprop(node, "ranges", base_ranges, nbase_ranges);
+ OF_getencprop(node, prop_name, base_ranges, nbase_ranges);
for (i = 0, j = 0; i < nranges; i++) {
ranges[i].pci_hi = base_ranges[j++];
@@ -704,6 +720,35 @@
return (nranges);
}
+int
+ofw_pcib_nranges(phandle_t node, struct ofw_pci_cell_info *info)
+{
+
+ return (ofw_pcib_nranges_impl("ranges", node, info));
+}
+
+static int
+ofw_pcib_fill_ranges(phandle_t node, struct ofw_pci_range *ranges)
+{
+
+ return (ofw_pcib_fill_ranges_impl("ranges", node, ranges));
+}
+
+int
+ofw_pcib_dma_nranges(phandle_t node, struct ofw_pci_cell_info *info)
+{
+
+ return (ofw_pcib_nranges_impl("dma-ranges", node, info));
+}
+
+static int
+ofw_pcib_fill_dma_ranges(phandle_t node, struct ofw_pci_range *ranges)
+{
+
+ return (ofw_pcib_fill_ranges_impl("dma-ranges", node, ranges));
+}
+
+
static struct rman *
ofw_pcib_get_rman(device_t bus, int type, u_int flags)
{
diff --git a/sys/dev/ofw/ofwpci.h b/sys/dev/ofw/ofwpci.h
--- a/sys/dev/ofw/ofwpci.h
+++ b/sys/dev/ofw/ofwpci.h
@@ -63,6 +63,8 @@
struct ofw_pci_range *sc_range;
int sc_nrange;
uint64_t sc_range_mask;
+ struct ofw_pci_range *sc_dma_range;
+ int sc_dma_nrange;
struct ofw_pci_cell_info *sc_cell_info;
struct rman sc_io_rman;
@@ -82,5 +84,6 @@
int ofw_pcib_write_ivar(device_t, device_t, int, uintptr_t);
int ofw_pcib_route_interrupt(device_t, device_t, int);
int ofw_pcib_nranges(phandle_t, struct ofw_pci_cell_info *);
+int ofw_pcib_dma_nranges(phandle_t, struct ofw_pci_cell_info *);
#endif /* _DEV_OFW_OFWPCI_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 5, 10:19 PM (8 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
40262905
Default Alt Text
D58106.id.diff (5 KB)
Attached To
Mode
D58106: ofw_pcib: add support for reading 'dma-ranges' property
Attached
Detach File
Event Timeline
Log In to Comment