[comp.sys.amiga] Resource Info Needed

eraps1@nadc (05/21/87)

From: eraps1@NADC


Hi,
Has anyone used the OpenResource() function?  Did you notice that there
is no corresponding CloseResource() function?  I am currently using the
CloseLibrary() function in its place since the RKM has the
OpenResource() function returning a pointer to a library structure.
Precisely what does the open command do?

When using the disk.resource, none of the functions listed in the
resource section of the RKM are available (ex. AllocUnit()).  They all
come up as unresolved externals.  When you allocate the disk resource,
is the cia resource automatically allocated as well? (the DiscResource
structure includes a ciaresource pointer).

Have I overlooked some documentation somewhere?  I have been
experimenting to find out some of these things, but I am to the point
now where I may need to start disassembling the OS to learn the answers.

Any and all help would be appreciated.

                                        - Rob Ginn (eraps1@nadc.arpa)

ps: Please respond directly to me since the info-amiga mailer is down.

dillon@CORY.BERKELEY.EDU (Matt Dillon) (05/21/87)

:Hi,
:Has anyone used the OpenResource() function?  Did you notice that there
:is no corresponding CloseResource() function?  I am currently using the
:CloseLibrary() function in its place since the RKM has the
:OpenResource() function returning a pointer to a library structure.
:Precisely what does the open command do?
:
:When using the disk.resource, none of the functions listed in the
:resource section of the RKM are available (ex. AllocUnit()).  They all
:come up as unresolved externals.  When you allocate the disk resource,
:is the cia resource automatically allocated as well? (the DiscResource
:structure includes a ciaresource pointer).

	OpenResource() simply returns a pointer to the resource and does
no allocation.  Though I agree a CloseResource() should have been put in,
it is not required.  You should *not* use CloseLibrary() in its place.

	The AllocUnit()/FreeUnit()/GetUnit()/etc.... routines are library
vectors off the the resource pointer returned by OpenResource().  Look at
resources/disk.h for the call offsets.  You have to write some assembly to
do place the proper arguments in the proper registers and make the call.

	Note, however, that the trackdisk drivers have already allocated
the drives in your system so AllocUnit() will most likely return failure.

	Assuming you are able to allocate a disk unit, you then gain control
of the disk controller with GetUnit(), do your disk operations, then release
the controller with GiveUnit() until you next need it (there are possibly
another 3 trackdisk tasks which may want to use it).

				-Matt