[comp.sys.mac.programmer] Are Inits loaded automatically?

g099508030ea@deneb.ucdavis.edu (Jim Deline) (05/24/88)

I am attempting to write an init and need to know an answer to the
following question: Does the Init 31 just run your Init's code, or
does it run it and also load it into the System heap?

I presume you have to load it yourself. If you know where this is 
documented besides tech notes, please let me know.

Better yet, if someone could either send me a pascal code fragment
showing how to do this, or send me the necessary tech notes in text
form. (via E-mail).

I appreciate any knowlegeable response. Thanks.

---Jim Deline--- U.C. Davis Chemistry Dept.

han@Apple.COM (Byron Han, Licensed To Dream) (05/24/88)

In article <2060@ucdavis.ucdavis.edu> jedeline@deneb.ucdavis.edu.UUCP (Jim Deline) writes:
>
>I am attempting to write an init and need to know an answer to the
>following question: Does the Init 31 just run your Init's code, or
>does it run it and also load it into the System heap?
>
>I presume you have to load it yourself. If you know where this is 
>documented besides tech notes, please let me know.
>
The INIT 31 mechanism looks at all files in the system folder of the boot
volume (aka the blessed folder) for files of type adev, cdev, rdev.
It then sees how many resources of type INIT are in each file and calls each
INIT resource by loading it into the system heap, placing a handle to the
INIT resource in A0 and JSR'ing to it.  It also increases the system heap 
size if needed as described in a technical note re the sysz resource.

Note that the INIT is NOT locked down.  To lock the resource down, just 
call _HLock from assembly (since A0 already contains the handle).
From pascal, use something like this:

     theHandle := RecoverHandle(@InitEntryPoint);
     HLock(theHandle);

where InitEntryPoint is the procedure name of the INIT's entry point.

Hope this helps.

-- 
Byron Han,  Licensed to Dream.             Macintosh - One Small Step For Apple.
Apple Computer, Inc. MS 27Y                ----One Giant Leap for Humankind.----
ATTnet:408-973-6450     applelink:HAN1     domain:han@apple.COM       MacNET:HAN
GENIE:BYRONHAN    COMPUSERVE:72167,1664    UUCP:{sun,voder,nsc,decwrl}!apple!han

darin@Apple.COM (Darin Adler) (05/24/88)

In article <10959@apple.Apple.Com> han@apple.UUCP (Byron Han, Licensed To Dream) writes:
> The INIT 31 mechanism looks at all files in the system folder of the boot
> volume (aka the blessed folder) for files of type adev, cdev, rdev.

He means of type 'INIT', 'cdev', and 'RDEV' (case sensitive).

> Note that the INIT is NOT locked down.  To lock the resource down, just 
> call _HLock from assembly (since A0 already contains the handle).

Or set the locked bit in the INIT resource.
-- 
Darin Adler					       AppleLink: Adler4
UUCP: {sun,voder,nsc,mtxinu,dual}!apple!darin	  CSNET: darin@Apple.com