Path: utzoo!utgpu!watserv1!watmath!att!pacbell.com!ucsd!swrinde!zaphod.mps.ohio-state.edu!usc!apple!stevec From: stevec@Apple.COM (Steve Christensen) Newsgroups: comp.sys.mac.programmer Subject: Re: RAM DRVRs, resLocked, dNeedLock Message-ID: <48483@apple.Apple.COM> Date: 25 Jan 91 20:33:33 GMT References: <1CE00001.e5yoxt@tbomb.ice.com> Organization: Apple Computer Inc., Cupertino, CA Lines: 46 time@ice.com writes: >martin@cs.uchicago.edu writes: >> I'm unclear about the relationship between RAM DRVRs, resLocked, and >> dNeedLock. Specifically: >> >> Does a resLocked DRVR effectively have dNeedLock? >> Does a dNeedLock DRVR effectively have resLocked? >> Isn't a DRVR always locked anyway between OpenDriver and CloseDriver? > >RAM drivers and ROM drivers have only one difference: > RAM based drivers are expected to provide a HANDLE in the dCtlDriver > field of the driver control entry. ROM based drivers are expected > to provide a POINTER in the dCtlDriver field. > > The driver control entry field "dCtlFlags" RAM-Based bit determines > whether or not the driver is RAM based (1) or not (0). > > As for the dNeedLock bit, if you are ROM based, set this bit. > This tells the Device Mgr to not lock the driver code. If you > are RAM based un-set this bit, so the Mgr knows to lock you down. > This is not intuitive, and you have to read the comment on page > II-188 very carefully. > > Don't worry about the ResLocked bit. RAM-based drivers don't need to provide a handle, and could, in fact, live in the middle of a heap block--the Device Manager doesn't care. The RAM/ROM bit basically determines how to get to the start of the driver, i.e., if it needs to de-reference a handle or just use the pointer, and also whether or not it needs to lock the handle while in the middle of a call. If you specify your driver to be "RAM-based" (referenced by a handle), then the driver will be locked only when the Device Manager calls it (Open, Close, Control, Status, Prime), and the rest of the time it will float in the heap. If you set the dNeedLock bit, then the driver will be locked down as long as it's open. This is only needed if some portion of the driver is called by someone other than the Device Manager. Examples of this are VBL routines and trap patches. steve -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Steve Christensen | Apple Computer, Inc. | Disclaimer: | 20525 Mariani Ave, MS-81CS | the above may be stevec@apple.com | Cupertino, CA 95014 | a lie...or not.