Page MenuHomeFreeBSD

D42740.id130484.diff
No OneTemporary

D42740.id130484.diff

diff --git a/sys/x86/x86/nexus.c b/sys/x86/x86/nexus.c
--- a/sys/x86/x86/nexus.c
+++ b/sys/x86/x86/nexus.c
@@ -97,13 +97,10 @@
static bus_add_child_t nexus_add_child;
static bus_print_child_t nexus_print_child;
-static bus_activate_resource_t nexus_activate_resource;
-static bus_adjust_resource_t nexus_adjust_resource;
static bus_alloc_resource_t nexus_alloc_resource;
-static bus_deactivate_resource_t nexus_deactivate_resource;
static bus_get_resource_list_t nexus_get_reslist;
+static bus_get_rman_t nexus_get_rman;
static bus_map_resource_t nexus_map_resource;
-static bus_release_resource_t nexus_release_resource;
static bus_unmap_resource_t nexus_unmap_resource;
#ifdef SMP
@@ -138,15 +135,16 @@
/* Bus interface */
DEVMETHOD(bus_print_child, nexus_print_child),
DEVMETHOD(bus_add_child, nexus_add_child),
- DEVMETHOD(bus_activate_resource, nexus_activate_resource),
- DEVMETHOD(bus_adjust_resource, nexus_adjust_resource),
+ DEVMETHOD(bus_activate_resource, bus_generic_rman_activate_resource),
+ DEVMETHOD(bus_adjust_resource, bus_generic_rman_adjust_resource),
DEVMETHOD(bus_alloc_resource, nexus_alloc_resource),
- DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
+ DEVMETHOD(bus_deactivate_resource, bus_generic_rman_deactivate_resource),
DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
DEVMETHOD(bus_get_resource_list, nexus_get_reslist),
+ DEVMETHOD(bus_get_rman, nexus_get_rman),
DEVMETHOD(bus_delete_resource, bus_generic_rl_delete_resource),
DEVMETHOD(bus_map_resource, nexus_map_resource),
- DEVMETHOD(bus_release_resource, nexus_release_resource),
+ DEVMETHOD(bus_release_resource, bus_generic_rman_release_resource),
DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource),
DEVMETHOD(bus_unmap_resource, nexus_unmap_resource),
#ifdef SMP
@@ -328,7 +326,7 @@
}
static struct rman *
-nexus_rman(int type)
+nexus_get_rman(device_t bus, int type, u_int flags)
{
switch (type) {
case SYS_RES_IRQ:
@@ -354,10 +352,7 @@
u_int flags)
{
struct nexus_device *ndev = DEVTONX(child);
- struct resource *rv;
struct resource_list_entry *rle;
- struct rman *rm;
- int needactivate = flags & RF_ACTIVE;
/*
* If this is an allocation of the "default" range for a given
@@ -376,81 +371,8 @@
count = rle->count;
}
- flags &= ~RF_ACTIVE;
- rm = nexus_rman(type);
- if (rm == NULL)
- return (NULL);
-
- rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == NULL)
- return (NULL);
- rman_set_rid(rv, *rid);
-
- if (needactivate) {
- if (bus_activate_resource(child, type, *rid, rv)) {
- rman_release_resource(rv);
- return (NULL);
- }
- }
-
- return (rv);
-}
-
-static int
-nexus_adjust_resource(device_t bus, device_t child, int type,
- struct resource *r, rman_res_t start, rman_res_t end)
-{
- struct rman *rm;
-
- rm = nexus_rman(type);
- if (rm == NULL)
- return (ENXIO);
- if (!rman_is_region_manager(r, rm))
- return (EINVAL);
- return (rman_adjust_resource(r, start, end));
-}
-
-static int
-nexus_activate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
-{
- struct resource_map map;
- int error;
-
- error = rman_activate_resource(r);
- if (error != 0)
- return (error);
-
- if (!(rman_get_flags(r) & RF_UNMAPPED) &&
- (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT)) {
- error = nexus_map_resource(bus, child, type, r, NULL, &map);
- if (error) {
- rman_deactivate_resource(r);
- return (error);
- }
-
- rman_set_mapping(r,&map);
- }
- return (0);
-}
-
-static int
-nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
-{
- struct resource_map map;
- int error;
-
- error = rman_deactivate_resource(r);
- if (error)
- return (error);
-
- if (!(rman_get_flags(r) & RF_UNMAPPED) &&
- (type == SYS_RES_MEMORY || type == SYS_RES_IOPORT)) {
- rman_get_mapping(r, &map);
- nexus_unmap_resource(bus, child, type, r, &map);
- }
- return (0);
+ return (bus_generic_rman_alloc_resource(bus, child, type, rid,
+ start, end, count, flags));
}
static int
@@ -523,20 +445,6 @@
return (0);
}
-static int
-nexus_release_resource(device_t bus, device_t child, int type, int rid,
- struct resource *r)
-{
- int error;
-
- if (rman_get_flags(r) & RF_ACTIVE) {
- error = bus_deactivate_resource(child, type, rid, r);
- if (error != 0)
- return (error);
- }
- return (rman_release_resource(r));
-}
-
/*
* Currently this uses the really grody interface from kern/kern_intr.c
* (which really doesn't belong in kern/anything.c). Eventually, all of

File Metadata

Mime Type
text/plain
Expires
Fri, Apr 3, 11:42 PM (19 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30785830
Default Alt Text
D42740.id130484.diff (4 KB)

Event Timeline