Messages in this thread | | | Date | Fri, 16 Jul 1999 02:13:27 +0200 (CEST) | From | Ingo Oeser <> | Subject | Re: New kernel/resource.c |
| |
On Fri, 9 Jul 1999, Linus Torvalds wrote:
> The thing is completely generic, and you can generate your own resources > if you want to. Resources have names and a "flag" value that they could > use if they cared to (I'd like to see the MTRR setup using resources, for > example, but that's up to Richard).
Could you please replace the "flags" member with a pointer to a structure "resource_class" ?
struct resource_operations { int (*use) (struct resource *); int (*unuse) (struct resource *); struct resource * (*get_alternate) (struct resource *); };
struct resource_class { struct resource_operations *ops; unsigned flags; void *data; /* private data */ };
This makes it way more generic in my opinion. And it allows to defer actual ressource allocation for use in PnP.
Please consider this example:
Driver A requests resource region R1 of root resource R. Driver B requests also region R2 of root resource R.
Now a PnP module (either loaded or statically compiled in) can try to resolve the conflict, by calling the operation "get_alternate" for one of them (or even both) and try using that instead, until "get_alternate" returns a "NULL" pointer. If it suceeds in finding disjunct resources for both of them, it calls "unuse" for all the wrong resources and "use" for the right ones.
The "data" member is ment for arbitary data, depending on the ressource, but requires also a valid "ops->unuse" member in case of being _not_ "NULL", to free it. "flags" is the old flags member.
You might also use the hierarchy, to have some "parents are responsible for their children" policy, in case of absence of any "ops".
Note, that release_region() has to try to call "ops->unuse()" now, and request_region() need to try to call "ops->use()" in order to wake the driver waiting for ackknowlegding its allocation try.
Suggested semantics of the ops:
use() (PnP-)System acknowledges the allocation to the driver. ("Your resource has been allocated, and you can use it now.") Driver marks this resource as "accessible" in its memory.
unuse() (PnP-)System refuses the allocation to the driver. ("Sorry, your resource allocation cannot be done.")
Driver marks this resource as "not accessible" in its memory and frees "data", or make it point to NULL, if it is a pointer to a static structure.
get_alternate() Try to obtain alternate resource regions, the driver can be configured to use. ("I'm not sure, whether I can commit this resource to you. Where else can you map your resource to?")
Driver returns a "struct resource *" with the same name, but different region and/or different "flags" (e.g. memory map the region instead of using IO) if possible. Otherwise it returns NULL. This process is an iteration! The driver can use for example the "data" member to track the iteration.
Comments?
Thanks for reading it
Regards
Ingo Oeser -- Feel the power of the penguin - run linux@your.pc <esc>:x
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |