Path: utzoo!attcan!uunet!snorkelwacker!ira.uka.de!smurf!urlichs From: urlichs@smurf.sub.org (Matthias Urlichs) Newsgroups: comp.sys.mac.programmer Subject: Re: CDEV/INIT Data Exchange, another way Keywords: cdev, INIT, system heap Message-ID: <90.161.17:10:07@smurf.sub.org> Date: 10 Jun 90 15:10:07 GMT References: <8560@goofy.Apple.COM> <1990Jun6.163604.12918@murdoch.acc.Virginia.EDU> <55103@microsoft.UUCP> Organization: University of Karlsruhe, FRG Lines: 40 In comp.sys.mac.programmer, article <55103@microsoft.UUCP>, benw@microsoft.UUCP (Ben WALDMAN) writes: < On cdev-INIT communication: < The way I do it is to write my what's really my INIT as a driver. < Then, the actual INIT resource opens the driver by name, putting into the < system heap. (And the driver's open routine patches the traps I want to < patch, etc.). The driver also provides a status call, which returns the < address of its globals. < < The cdev, when it wants to communicate with the INIT, can simply < look through the unit table (this is described in a tech note), and find < the driver (by name). Then, the cdev can make a status call to the driver, When you already know the driver's name, why not do an OpenDriver(name)? That'll get you its refnum much easier and safer (WRT compatibility). Apple specifically recommends not to scan the unit table if at all possible. < and, voila, the status call returns the info the driver needs. In my case, < I returned a pointer to the INITs globals (the init is locked in memory), < but you could, of course, return a handle, or an address of a function you < wanted to call, etc. < If you want the driver to do anything, it'd be much cleaner just to call the driver through _Control and/or _Status calls, no? That way the whole thing will also work if the user boots with version X of your driver, then installs Y (not necessarily greater than X), and opens the control panel... < The scheme fails if a dorky user changes the name of the DRVR resource < with ResEdit, but will still succeed if the DRVR gets renumbered. < You'll _have_to_ check in the unit table for a free refnum and install your driver there. You may have to make the unit table bigger; don't forget to zero the new table, record the new size in the appropriate global, don't free the old table because you don't know where it came from, and turn off interrupts while you do it. -- Matthias Urlichs -- urlichs@smurf.sub.org -- urlichs@smurf.ira.uka.de Humboldtstrasse 7 - 7500 Karlsruhe 1 - FRG -- +49+721+621127(Voice)/621227(PEP)