DragonFly submit List (threaded) for 2007-09
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Re: [PATCH] Bring in the latest agp code from FreeBSD HEAD
Oops! The agp patch requires one more patch from my queue. It's attached
to this mail. Any objections to commit this?
And i810 crash issue I had, turned out to be a documented feature - i810
doesn't allocate offscreen memory by default, seems. The "LinearAlloc"
option helps. Really weird ... Thanks to anyone pointing me to this.
--
Hasso
# HG changeset patch
# User Hasso Tepper <hasso@estpak.ee>
# Date 1189417456 -10800
# Branch HEAD
# Node ID d331609b916a50a7f6c4ff52ee2f0436c38c65cd
# Parent 7c11353afd8ef8ac40acb4827e2304bd0a2c4459
Add bus_alloc_resources()/bus_release_resources() functions.
They simplify the code and make porting drivers (initially agp) from
FreeBSD easier.
Obtained-from: FreeBSD
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -2319,6 +2319,39 @@ bus_generic_child_present(device_t bus,
* less-wordy code. In the future, it might make sense for this code
* to maintain some sort of a list of resources allocated by each device.
*/
+int
+bus_alloc_resources(device_t dev, struct resource_spec *rs,
+ struct resource **res)
+{
+ int i;
+
+ for (i = 0; rs[i].type != -1; i++)
+ res[i] = NULL;
+ for (i = 0; rs[i].type != -1; i++) {
+ res[i] = bus_alloc_resource_any(dev,
+ rs[i].type, &rs[i].rid, rs[i].flags);
+ if (res[i] == NULL) {
+ bus_release_resources(dev, rs, res);
+ return (ENXIO);
+ }
+ }
+ return (0);
+}
+
+void
+bus_release_resources(device_t dev, const struct resource_spec *rs,
+ struct resource **res)
+{
+ int i;
+
+ for (i = 0; rs[i].type != -1; i++)
+ if (res[i] != NULL) {
+ bus_release_resource(
+ dev, rs[i].type, rs[i].rid, res[i]);
+ res[i] = NULL;
+ }
+}
+
struct resource *
bus_alloc_resource(device_t dev, int type, int *rid, u_long start, u_long end,
u_long count, u_int flags)
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -252,6 +252,17 @@ int bus_generic_rl_release_resource (dev
* Wrapper functions for the BUS_*_RESOURCE methods to make client code
* a little simpler.
*/
+struct resource_spec {
+ int type;
+ int rid;
+ int flags;
+};
+
+int bus_alloc_resources(device_t dev, struct resource_spec *rs,
+ struct resource **res);
+void bus_release_resources(device_t dev, const struct resource_spec *rs,
+ struct resource **res);
+
struct resource *bus_alloc_resource(device_t dev, int type, int *rid,
u_long start, u_long end, u_long count,
u_int flags);
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]