Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!stjhmc!p12.f56.n114.z1.fidonet.org!Chris.Gehlker From: Chris.Gehlker@p12.f56.n114.z1.fidonet.org (Chris Gehlker) Newsgroups: comp.sys.mac.programmer Subject: RE: Problems installing interrupt handler (INIT part 2) Message-ID: <30417.27493A91@stjhmc.fidonet.org> Date: 20 Nov 90 14:14:31 GMT Sender: ufgate@stjhmc.fidonet.org (newsout1.26) Organization: FidoNet node 1:114/56.12 - AZ MAC UG, Phoenix AZ Lines: 49 In a message > From: nugteren@pttrnl.nl Nils Nugteren asks: > I have written an interrupt handler in Think C, that catches incoming > characters from the serial port and manipulates these in the background > (i.e. invisible to the user). It works fine as an application, but I > am having troubles installing it in the background (memory resident etc.). > I'm new to MacIntosh programming so I would appreciate any help greatly. Nils, my serial drivers patch themselves into the level 2 dispand reprogram the SCC completely. What you are trying to do is somewhat different so take these suggestions with a grain of salt. > Also, the program must be combined with an INIT somehow, because it has to > startup and install itself in the background in startup time. Should I convert > the whole program to an INIT or create a loader INIT that loads the code in > separately ? Use an INIT that loads the driver and then calls DetachResource() on it so that the driver won't get purged by the INIT31 mechanism. The part of the INIT that does the ShowIcon stuff can go away. Also set the SysHeap and Locked bits in the driver. > The program uses global variables (but not QuickDraw). > I gather this may be somewhat of a problem in an INIT. Or does Think C take > care of this problem by using register A4 to address globals ? Using A4 works for me. > The program should stay resident indefinitely and not be reinitialised. > Do I have to load it into the system heap? How do I do this with Think C ? For some reason THINK C gives you a pop-up menu to set the resource bits for code resources but not for drivers. What I do is compile my cdev to disk. Then I compile the INIT that opens the driver and merge like it into the cdev. Then I compile my driver into a file of type rsrc with creator RSED. When I double click this file it launches ResEdit and I have the ResEdit menu customized to open my cdev-INIT from the Open Special Menu. I set both the DRVR and the DATA resources to SysHeap and Locked and paste them into the INIT-cdev. Then I just shove the DRVR-INIT-cdev file into the system folder and reboot. -- Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!56.12!Chris.Gehlker Internet: Chris.Gehlker@p12.f56.n114.z1.fidonet.org