git: 672a0a76ed4a - stable/14 - simplebus: Consistently map SYS_RES_IOPORT to SYS_RES_MEMORY
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 27 Feb 2025 14:16:45 UTC
The branch stable/14 has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=672a0a76ed4ab2fbcad7bc668b1f2dd1a8f09766
commit 672a0a76ed4ab2fbcad7bc668b1f2dd1a8f09766
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-01-23 17:38:25 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-02-27 13:09:20 +0000
simplebus: Consistently map SYS_RES_IOPORT to SYS_RES_MEMORY
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D43442
(cherry picked from commit 3cf553288b968106e40882bb73b30da652614ba0)
---
sys/dev/fdt/simplebus.c | 90 +++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 83 insertions(+), 7 deletions(-)
diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c
index db357b190d9e..273e77abd642 100644
--- a/sys/dev/fdt/simplebus.c
+++ b/sys/dev/fdt/simplebus.c
@@ -47,6 +47,19 @@
static int simplebus_probe(device_t dev);
static struct resource *simplebus_alloc_resource(device_t, device_t, int,
int *, rman_res_t, rman_res_t, rman_res_t, u_int);
+static int simplebus_adjust_resource(device_t bus, device_t child,
+ int type, struct resource *r, rman_res_t start, rman_res_t end);
+static int simplebus_release_resource(device_t bus, device_t child,
+ int type, int rid, struct resource *r);
+static int simplebus_activate_resource(device_t bus,
+ device_t child, int type, int rid, struct resource *r);
+static int simplebus_deactivate_resource(device_t bus,
+ device_t child, int type, int rid, struct resource *r);
+static int simplebus_map_resource(device_t bus, device_t child,
+ int type, struct resource *r, struct resource_map_request *args,
+ struct resource_map *map);
+static int simplebus_unmap_resource(device_t bus, device_t child,
+ int type, struct resource *r, struct resource_map *map);
static void simplebus_probe_nomatch(device_t bus, device_t child);
static int simplebus_print_child(device_t bus, device_t child);
static device_t simplebus_add_child(device_t dev, u_int order,
@@ -84,10 +97,12 @@ static device_method_t simplebus_methods[] = {
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
DEVMETHOD(bus_alloc_resource, simplebus_alloc_resource),
- DEVMETHOD(bus_release_resource, bus_generic_release_resource),
- DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
- DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
- DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
+ DEVMETHOD(bus_release_resource, simplebus_release_resource),
+ DEVMETHOD(bus_activate_resource, simplebus_activate_resource),
+ DEVMETHOD(bus_deactivate_resource, simplebus_deactivate_resource),
+ DEVMETHOD(bus_adjust_resource, simplebus_adjust_resource),
+ DEVMETHOD(bus_map_resource, simplebus_map_resource),
+ DEVMETHOD(bus_unmap_resource, simplebus_unmap_resource),
DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource),
DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
DEVMETHOD(bus_child_pnpinfo, ofw_bus_gen_child_pnpinfo),
@@ -433,6 +448,9 @@ simplebus_alloc_resource(device_t bus, device_t child, int type, int *rid,
sc = device_get_softc(bus);
+ if (type == SYS_RES_IOPORT)
+ type = SYS_RES_MEMORY;
+
/*
* Request for the default allocation with a given rid: use resource
* list stored in the local device info.
@@ -441,9 +459,6 @@ simplebus_alloc_resource(device_t bus, device_t child, int type, int *rid,
if ((di = device_get_ivars(child)) == NULL)
return (NULL);
- if (type == SYS_RES_IOPORT)
- type = SYS_RES_MEMORY;
-
rle = resource_list_find(&di->rl, type, *rid);
if (rle == NULL) {
if (bootverbose)
@@ -481,6 +496,67 @@ simplebus_alloc_resource(device_t bus, device_t child, int type, int *rid,
count, flags));
}
+static int
+simplebus_adjust_resource(device_t bus, device_t child, int type,
+ struct resource *r, rman_res_t start, rman_res_t end)
+{
+
+ if (type == SYS_RES_IOPORT)
+ type = SYS_RES_MEMORY;
+ return (bus_generic_adjust_resource(bus, child, type, r, start, end));
+}
+
+static int
+simplebus_release_resource(device_t bus, device_t child, int type, int rid,
+ struct resource *r)
+{
+
+ if (type == SYS_RES_IOPORT)
+ type = SYS_RES_MEMORY;
+ return (bus_generic_release_resource(bus, child, type, rid, r));
+}
+
+static int
+simplebus_activate_resource(device_t bus, device_t child, int type, int rid,
+ struct resource *r)
+{
+
+ if (type == SYS_RES_IOPORT)
+ type = SYS_RES_MEMORY;
+ return (bus_generic_activate_resource(bus, child, type, rid, r));
+}
+
+static int
+simplebus_deactivate_resource(device_t bus, device_t child, int type, int rid,
+ struct resource *r)
+{
+
+ if (type == SYS_RES_IOPORT)
+ type = SYS_RES_MEMORY;
+ return (bus_generic_deactivate_resource(bus, child, type, rid, r));
+}
+
+static int
+simplebus_map_resource(device_t bus, device_t child, int type,
+ struct resource *r, struct resource_map_request *args,
+ struct resource_map *map)
+{
+
+ if (type == SYS_RES_IOPORT)
+ type = SYS_RES_MEMORY;
+ return (bus_generic_map_resource(bus, child, type, r, args, map));
+}
+
+static int
+simplebus_unmap_resource(device_t bus, device_t child, int type,
+ struct resource *r, struct resource_map *map)
+{
+
+ if (type == SYS_RES_IOPORT)
+ type = SYS_RES_MEMORY;
+ return (bus_generic_unmap_resource(bus, child, type, r, map));
+}
+
static int
simplebus_print_res(struct simplebus_devinfo *di)
{